2013-03-14 110 views
2

對於我的Windows Phone應用程序,我正在通過列出確切的文件將我的文件複製到isostorage。將整個文件夾複製到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); 
     } 
    } 
} 

是否可以複製整個文件夾而不是列出我要複製的文件?

回答

1

您可以在foreach循環中執行此操作,但您需要首先收集所有嵌入式資源的列表。您可以使用Assembly.GetManifestResourceNames來檢索它們。

+0

我沒有讓GetManifestResourceNames返回正確的資源列表。你能舉一個例子嗎? – Thys 2013-03-14 16:13:25

+0

*剛剛發現GetManifestResourceNames返回一個包含資源的文件。你還能發佈並舉例嗎? :P – Thys 2013-03-14 16:23:57

相關問題