문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top