문제

Namely, a file that lives here: https://dl.dropboxusercontent.com/u/19417676/snowbird_confusion.png (image linked due to lack of reputation to post directly)

Tutorials and documentation encourage the use of Windows.Storage namespace, but when when running my project and enumerating every file and folder in Windows.Storage.ApplicationData, it's revealed that nothing exists in there. Furthermore, nothing exists in the Local, Roaming or Temp folders either.

Using Windows.ApplicationModel.Package.Current.InstalledLocation gets me close, but it puts me in the ...\Debug\AppX directory. When viewing the built project structure, the actual folder containing my .rtf file lives in ...\Debug\Tales, and WinRT applications are very restrictive about walking directory structures (not to mention it probably wouldn't be portable to the Windows Phone anyway).

So, how do I access this file?

도움이 되었습니까?

해결책

Figured it out. I had correctly set my .rtf file to Copy to output dir: Copy Always, but had forgotten to change its Build Action to Content.

The below code now works just fine.

StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
folder = await folder.GetFolderAsync("MyFolder");
StorageFile file= await folder.GetFileAsync("MyFile.rtf");
string rtfString = await Windows.Storage.FileIO.ReadTextAsync(file);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top