uwp inability append text to File

0

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 + "\r\n");

      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()}

c#
file
uwp
asked on Stack Overflow Aug 12, 2018 by radin • edited Aug 13, 2018 by TheTanic

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0