Search code examples
.netfile-iowindows-store-appsstreamwriter

how to write text to a file in .net for windows store.. for crying out loud


I have a list of strings.

I want to output them to a txt file.

Very simple in .net traditionally, even done with a single line of code.

However with .net for windows store:

File.writeAllLines - doesnt work using streamwriter - doesnt work

for crying out loud. please. somebody. help.


Solution

  • One of the easiest ways:

    var myFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("myFile.txt", CreationCollisionOption.ReplaceExisting);
    await FileIO.WriteTextAsync(myFile, "string content");