由网友(枫叶羽)分享简介:我有一个使用一些XML文件的类库在自己的目录中找到。I have a class library that uses some xml files found in its own directory.当从其他项目引用这个库,我怎么确保库是从它自己的目录中工作?When referencing this libr...
我有一个使用一些XML文件的类库在自己的目录中找到。
I have a class library that uses some xml files found in its own directory.
当从其他项目引用这个库,我怎么确保库是从它自己的目录中工作?
When referencing this library from another project, how do I ensure the library is working from it's own directory?
我试过Assembly.GetExecutingAssembly()的位置,但仍返回启动项目的路径。
I tried Assembly.GetExecutingAssembly().Location but that still returns the path of the startup project.
推荐答案
我知道这是旧的文章,但在事件别人绊倒它从搜索,我发现这样做最简单的方法是:
I know this is an old post but in the event someone else stumbles on it from a search, the easiest way I've found to do this is:
Public Class Foo
Public Shared Function GetMyPath() As String
Return Path.GetDirectoryName(GetType(Foo).Assembly.Location)
End Function
End Class
相关推荐
最新文章