如何从Windows便携式类库中读取文本文件 [英] How to read a text file from windows portable class library
问题描述
我是MVVMCross的新手,请从资源文件夹中读取文件。有什么想法吗?
我尝试了什么:
var assembly = typeof(Assembly).GetTypeInfo()。汇编;
string [] resources = assembly.GetManifestResourceNames();
流stream = assembly.GetManifestResourceStream(QueueResponse.txt );
但是将资源变为空。
我认为你需要在文件名QueueResponse.txt前添加名称空间。大会,即
流stream = 汇编 .GetManifestResourceStream(< span class =code-string> MyNamespace.QueueResponse.txt);
显然是MyNamespace!=你的名字空间 - 使用汇编构建的实际值
I am new to MVVMCross, tring to read a file from resource folder. Any ideas?
What I have tried:
var assembly = typeof(Assembly).GetTypeInfo().Assembly;
string[] resources = assembly.GetManifestResourceNames();
Stream stream = assembly.GetManifestResourceStream("QueueResponse.txt");
but getting resources as empty.解决方案I think you need to prefix the filename "QueueResponse.txt" with the namespace of the Assembly, ie
Stream stream = assembly.GetManifestResourceStream("MyNamespace.QueueResponse.txt");
obviously MyNamespace != your name space - use the actual value the assembly was built with
这篇关于如何从Windows便携式类库中读取文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!