點擊後按鈕後,我想出了自己。這blog post描述如何使用嵌入的資源作爲圖像。
當您添加文件到客戶端的項目,你必須設置生成操作爲「嵌入的資源」,然後你可以用下面的代碼獲取流:
// get the currently executing assembly
Assembly assembly = Assembly.GetExecutingAssembly();
// list all available ResourceName's
string[] resources = assembly.GetManifestResourceNames();
// creates a StreamReader from the TestFile.txt
StreamReader sr = new StreamReader(assembly
.GetManifestResourceStream("LightSwitchApplication.TestFile.txt"));
// puts the content of the TestFile.txt in a string
string text = sr.ReadToEnd();