将整个文件夹复制到IsoStorage
本文关键字:IsoStorage 复制 文件夹 | 更新日期: 2023-09-27 18:04:06
对于我的Windows Phone应用程序,我目前正在通过列出确切的文件将我的文件复制到isostorage。
string[] files = { "index.html", "style.css", "jquery.js" };
foreach (string f in files)
{
Uri fileUri = new Uri(componentPrefix + f, UriKind.Relative);
StreamResourceInfo sr = Application.GetResourceStream(fileUri);
if (sr == null)
{
// we are probably a folder or non-existing file
}
else
{
using (BinaryReader br = new BinaryReader(sr.Stream))
{
byte[] data = br.ReadBytes((int)sr.Stream.Length);
IsoStoreUtils.SaveToIsoStore(f, data);
}
}
}
是否可以复制整个文件夹而不是列出我想要复制的文件?
您可以在foreach循环中做到这一点,但是您需要首先收集所有嵌入资源的列表。您可以使用Assembly.GetManifestResourceNames来检索它们。