每当我需要进行路径解析时,都感到困惑。以下是关于报告问题的信息:
- 使用
ASP.NET MVC-5应用程序
- 尝试通过下面的代码访问
字体文件
,即MyriadPro-SemiBold.ttf
//a value receives a path + name of the file in variable i.e. name
string name = "myApplicationName.fonts.MyriadPro-Semibold.ttf";
//object (named as assembly) of class System.Reflection.Assembly.
var assembly = Assembly.GetExecutingAssembly();
using (Stream stream = assembly.GetManifestResourceStream(name))
// stream always gets null value (don't know why!)
{
if(stream != null)
{
//myCode waiting for above stream not to be null :-(
}
else
{
throw new ArgumentException("No resource with name " + name);
}
}
我对于在不同类型的应用程序中,Visual Studio在路径方面的工作方式并不了解。