5
A
回答
11
根据MSDN(App Object Changes in Visual Basic .NET),更换为两个是
System.Reflection.Assembly.GetExecutingAssembly().Location
它包含完整路径(App.Path
)以及文件名(App.EXEName
)。
' Import System.Reflection and System.IO at the top of your class file
Dim location = Assembly.GetExecutingAssembly().Location
Dim appPath = Path.GetDirectoryName(location) ' C:\Some\Directory
Dim appName = Path.GetFileName(location) ' MyLibrary.DLL
UPDATE(感谢评论者):可以使用从Path
类的辅助方法拆分信息,如果你是在一个DLL执行此代码,你想要的名称那个叫EXE的DLL,你需要用GetEntryAssembly
而不是GetExecutingAssembly
。请注意,如果您的DLL是从非托管EXE调用的,则GetEntryAssembly
可能会返回Nothing
。
相关问题
- 1. 什么是VB.NET中Program.cs的等效物
- 2. vb.net中nslookup的等效物是什么?
- 3. 在c#中VB6 App.Path的等价性是什么?
- 4. 什么是在C#中的VB.net Len(Dir(stringVal))的等效代码
- 5. 什么是Apache配置的等效值
- 6. 什么是Eval(“this”)的等效值
- 7. VB.NET中的“yield return”等效语法是什么?
- 8. 什么是等效的lambda?
- 9. 什么是[Android] Java的等效VB.NET的静态关键字?
- 10. C#中的等效语法是什么?
- 11. 什么是SFTP中的等效ftp_chdir?
- 12. PowerShell中'nohup'的等效物是什么?
- 13. Dart中Platform.flush()的等效物是什么?
- 14. openpyxl中的等效函数是什么?
- 15. Qt中的等效std :: deque是什么?
- 16. DevExpress中RibbonRadioButton的等效项是什么?
- 17. Cocoa中的等效C#'Thread.Join()'是什么?
- 18. 什么是C#中的等效代码#
- 19. 什么是Xamarin.iOS中的等效CGPointZero?
- 20. phpMyAdmin中的等效星号(*)是什么?
- 21. 什么是NodaTime中的System.TimeZoneInfo.IsDaylightSavingTime等效项?
- 22. 什么是Silverlight中的Response.Redirect等效项?
- 23. 什么是C#winform中的等效UpdateSourceTrigger?
- 24. jquery中的等效物是什么
- 25. 是什么在vb6壳牌(App.Path& “\” & “HELLO.EXE”)和壳( “HELLO.EXE”)之间的差值
- 26. 与ListView控件中的DataList的EditItemIndex的等效值是什么?
- 27. 与R的Excel中的LEFT()和RIGHT()等效的是什么?
- 28. ASP.net(VB.net)中ASP(VB)Server.CreateObject(“ADOX.Catalog”)的等效什么
- 29. VB.NET中的typedef的等效方法或解决方法是什么?
- 30. 什么是android的openssl_public_encrypt等效的php?
你没有得到那个权利,他想要的是EXE路径,而不是DLL路径。使用Assembly.GetEntryAssembly()代替。 – 2012-02-06 16:53:25
我在使用DLL我认为我需要Assembly.GetEntryAssembly() – 2012-02-06 16:59:39
@HansPassant:谢谢,修正! – Heinzi 2012-02-06 17:21:44