So I want to create a simple text file with this code.
But when I open the created file , the text is not displayed entirely,
the only text I got is from tb1.text (id[2]).
Is there anything wrong here?
private async void Save_Reg()
{
var myfile = (tb3.Text+".xml");
var folderUsed = ApplicationData.Current.LocalFolder;
var folderOp = Windows.Storage.CreationCollisionOption.ReplaceExisting;
var createFile = await folderUsed.CreateFileAsync(myfile, folderOp);
var password = tb2.Text;
var recov = tb1.Text;
string[] id = { myfile,password, recov };
await Windows.Storage.FileIO.WriteTextAsync(createFile, id[0]);
await Windows.Storage.FileIO.WriteTextAsync(createFile, id[1]);
await Windows.Storage.FileIO.WriteTextAsync(createFile, id[2]);
}
Yes.
WriteTextAsyncreplaces the contents of the current file. It’s equivalent to the synchronousFile.WriteAllTextmethod. If you want to append, you’ll needAppendTextAsync.Alternatively, concatenate the ids so you know the full contents you want to write, and then call
WriteTextAsyncjust once.