UnauthorizedAccessException C# File.IO Async

I had to upgrade one application and put some extra functionality. So i added an async function that handles a .txt file and edit some fields.

So i used this code

StorageFolder storageFolder = ApplicationData.Current.RoamingFolder;
 storageFile = await storageFolder.CreateFileAsync("file.txt",CreationCollisionOption.ReplaceExisting);
await FileIO.AppendTextAsync(storageFile, "saveSomeText");


But i also had a function in MainPage that asynchronously was reading the same file

StorageFolder storageFolder = ApplicationData.Current.RoamingFolder;
StorageFile storageFile;
storageFile = await storageFolder.CreateFileAsync("file.txt",CreationCollisionOption.OpenIfExists);
IList<string> list = await FileIO.ReadLinesAsync(storageFile);


Both functions were async so we could not determine when each function was running and which will be executed first.

So when i tried to run the app i came across with UnauthorizedAccessException because both function maybe were trying to access the file the same time. So i have to make one function wait. You can achieve that by many ways. I used the below function.


            async void waitsomething()
                await Task.Delay(2000);


But i want to execute this code only once. So i used localSettings

                    tempstr = App.localSettings.Values["YOURkey"].ToString();
                catch (NullReferenceException exmas)



How to install Windows 10 Technical Preview on Microsoft Hyper V (Windows 8.1 pro)

Here are the steps that you need to follow in order to install Windows 10 tech preview on Microsoft Hyper-V.

First of all go and download the .iso from


  1. Run hyper-v and click New -> Virtual Machine start-step
  2. Press next step1
  3. Give a name for the new virtual machine 
  4. Click Generation 1step3
  5. Provide ram size (suggest: 2 GB and more)step4
  6. Choose Not Connected for now.We will change that laterstep5
  7. Give your hard disk a size. You can store your virtual hard disc anywhere you want.You can also select one that already exists.step6
  8. Choose the bootable iso that you have downloaded from the windows insider pagestep7
  9. Press finishstep8
  10. Go to virtual switch managerstart-step
  11. New virtual network switch -> External
  12. Choose your network adapter and give virtual switch a namestep11
  13. Then select Settings -> Network Adapter -> and choose that you created on the previous stepstep12
  14. You are ready to rock!windows10-screenshot

Override the default style of an element – Windows 8.1 aps

One simple way to override the default style of an element on Windows Store aps can be done by changing the default styles. So first of all google for those styles and when you find them just edit and paste in


For example i wanted to make a ToggleSwitch Black. So i found all the available styles and i just modified those i wanted. Then in App.xaml you could see that

<SolidColorBrush x:Key="SearchBoxButtonBackgroundThemeBrush" Color="Black" />
<SolidColorBrush x:Key="ToggleSwitchCurtainBackgroundThemeBrush" Color="Black" />
<SolidColorBrush x:Key="ToggleSwitchCurtainDisabledBackgroundThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="ToggleSwitchCurtainPointerOverBackgroundThemeBrush" Color="Black" />
<SolidColorBrush x:Key="ToggleSwitchCurtainPressedBackgroundThemeBrush" Color="Black" />