简体   繁体   中英

How do I use Windows.Storage.FileIO.WriteFileAsync in Windows 8.1?

I'm trying to write a text file to the roaming folder in my Windows 8.1 app. However, all the tutorials I've been able to find were written for Windows 8 and use the Windows.Storage.FileIO.WriteFileAsync method which is no longer available in Windows 8.1 apparently. What is the equivalent method for this in 8.1?

Here's the code I have so far, I just don't know what do afterwards to write the file because of the apparent change in APIs:

var applicationData = ApplicationData.Current;
var roamingFolder = applicationData.RoamingFolder;

await roamingFolder.CreateFileAsync("file.txt", CreationCollisionOption.GenerateUniqueName);

I've never heard of Windows.Storage.File.IO.WriteFileAsync . You're probably looking for Windows.Storage.FileIO which has WriteBytesAsync , WriteTextAsync , etc .

I figured out the issue. When I used that method in Windows 8, I would type in the full Windows.Storage.FileIO line, but now in Windows 8.1, I only need to type in File.IO.WriteTextAsync() and it'll work. The Windows.Storage part is no longer needed in Windows 8.1 it seems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM