【发布时间】:2012-10-03 03:24:19
【问题描述】:
我尝试创建一个从“资源”文件中读取的简单应用程序,该文件已添加到我的解决方案中。我已经尝试过了,但这不起作用:
static void Main(string[] args)
{
StreamResourceInfo streamResourceInfo = Application.GetContentStream(new Uri("pack://application:,,,/myfile.txt", UriKind.Absolute));
StreamReader sr = new StreamReader(streamResourceInfo.Stream);
var content = sr.ReadToEnd();
Console.WriteLine(content);
}
它说:“无效的 URI:指定的端口无效。”
我该如何解决这个问题?
【问题讨论】:
-
你检查how to read embedded ressource file了吗?我认为这应该可以帮助您!
-
谢谢!帮了大忙!