uwp inability append text to File

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



uwp inability append text to File



I create a text file by this code:


StorageFile file = await DownloadsFolder.CreateFileAsync(
listFile.Name, CreationCollisionOption.GenerateUniqueName);

try

await FileIO.AppendTextAsync(file, user.ID + ", " + user.Username + ","
+ name + ", " + user.Follower + ", " + user.Following + ", "
+ user.Post + ", " + user.MidLike + ", " + user.Public + ", "
+ Biography + ", " + user.LastPage.ToShortDateString() + ", "
+ user.Kind + ", " + user.Like + ", " + user.CM + ", "
+ user.View + ", " + Cap + "rn");

await CachedFileManager.CompleteUpdatesAsync(file);

catch(Exception ex)

MessageDialog message = new MessageDialog(ex.ToString());
await message.ShowAsync();



Sometimes I get the following error:



System.Exception: Unable to remove the file to be replaced. (Exception from HRESULT: 0x80070497)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Khorma.CommandPage.d__6.MoveNext()





Do you have any other code to remove the file? I tried your above code but could not reproduce it, could you provide a reproducible sample? By the way, in your above code, it seems you use varibile File and file, are they the same one?
– Breeze Liu - MSFT
Aug 13 at 5:50





Can you please call CachedFileManager.DeferUpdates(file); before FileIO.AppendTextAsync?
– TheTanic
Aug 13 at 7:08









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS