点击后按钮后,我想出了自己。这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();