Assembly门类无法加载自己的文件啊为什么
Assembly类型无法加载自己的文件啊,为什么?
我创建了一个C#的控制台程序,里面增加了一个xml文件叫做XMLFile.xml文件,添加了一些内容:
然后fs是null。这是为什们? 如果获取FileStream失败,为什么没有抛出异常,而是null呢?
有什么解释吗?
谢谢。
------解决方案--------------------
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getfile(v=vs.110).aspx
Return Value
Type: System.IO.FileStream
A stream that contains the specified file, or null if the file is not found.
null就是没有找到。
我创建了一个C#的控制台程序,里面增加了一个xml文件叫做XMLFile.xml文件,添加了一些内容:
Assembly a = Assembly.GetEntryAssembly();
Console.WriteLine(a.FullName);
FileStream fs=a.GetFile(@"XMLFile1.xml");
然后fs是null。这是为什们? 如果获取FileStream失败,为什么没有抛出异常,而是null呢?
有什么解释吗?
谢谢。
------解决方案--------------------
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getfile(v=vs.110).aspx
Return Value
Type: System.IO.FileStream
A stream that contains the specified file, or null if the file is not found.
null就是没有找到。