How to write txt file in windows app store?

眉间皱痕 提交于 2019-11-27 19:39:13

问题


i have been searching all night to figure out how to write txt file to a specific location like D:\ i tried the StreamWriter and System.IO.File which is not included in the app store applications with no luck so far i would appreciate any help.


回答1:


You can't write to any location from Windows Store apps because they are sandboxed, you can only write to app's local folder:

string text = "Hello, world";

StorageFolder folder = ApplicationData.Current.LocalFolder;
StorageFile file = await folder.CreateFileAsync("data.txt");

if (file != null)
{
    await FileIO.WriteTextAsync(file, text);
}



回答2:


You might want to checkout FileIO class, more specifically Writetextasync method for writing text files.



来源:https://stackoverflow.com/questions/22551575/how-to-write-txt-file-in-windows-app-store

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!