


Initialize the HttpClient and set the progress handler var client = new HttpClient() Progress progressCallback = new Progress(httpProgressCallback) ĥ. Retrieve the FileStorage object StorageFile file = await savePicker.PickSaveFileAsync() Ĥ.

Var savePicker = new ()) savePicker.SuggestedFileName = photo.Id // pre-fill file's nameģ.

StorageFolder localFolder = // Create a new file in the app's local folder. Here is a quick sample: using System using Windows.Storage // Get the app's local folder to use as the destination folder. But you must provide a StorageFile object to save the image to the device’s storage. Tempstr = : If you don’t want to use a FileSavePickerin your app, skip the first three steps. I used the below function.īut i want to execute this code only once. 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. IList list = await FileIO.ReadLinesAsync(storageFile) īoth functions were async so we could not determine when each function was running and which will be executed first. StorageFile = await storageFolder.CreateFileAsync("file.txt",CreationCollisionOption.OpenIfExists) StorageFile = await storageFolder.CreateFileAsync("file.txt",CreationCollisionOption.ReplaceExisting) Īwait FileIO.AppendTextAsync(storageFile, "saveSomeText") īut i also had a function in MainPage that asynchronously was reading the same file StorageFolder storageFolder = So i used this code StorageFolder storageFolder = So i added an async function that handles a. I had to upgrade one application and put some extra functionality.
