[英]How to export a file from the Assets folder to the phone's Documents folder in Windows Phone 8.1 RT?
[英]Write to a text file in my project's assets folder Windows Phone 8.1
我试图写入项目资产文件夹中的文本文件。 该程序运行无误,但在文本文件中看不到任何内容。 谁能帮帮我吗?
StorageFolder asset_folder = await Package.Current.InstalledLocation.GetFolderAsync("Assets");
StorageFile asset_file = await asset_folder.CreateFileAsync("TextFile1.txt", CreationCollisionOption.ReplaceExisting);
using(Stream s_Asset = await asset_file.OpenStreamForWriteAsync())
{
await s_Asset.WriteAsync(data, 0, data.Length);
}
Build Action也设置为Content 。
让我知道我是否在某处出错了...
您无法写入Package.Current.InstalledLocation-它是只读的。 如果要在此处添加某些内容,则必须在生产期间进行。
如果要在应用程序中写入一些文件,请使用ApplicationData.LocalFolder 。
您还将在MSDN上找到更多帮助。
您无法从应用程序修改包内容。 因此,要写入文件,必须将文件从资产文件夹复制到应用程序的IsolatedStorage。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.