如何在WinForm应用程序项目中获取目录的路径

4 vb.net directory projects-and-solutions startup

我在.net中的winform项目中有一个名为reports的目录.我的项目名称是AccountingReports,内部存在目录报告.所以我需要通过代码访问此路径的方法.在Asp.net中,我们使用Request.PhysicalApplicationPath属性.那么是否存在任何方法或属性将为我提供项目的根目录

Chr*_*isF 10

您可以使用:

Directory.GetCurrentDirectory

获取应用程序的当前工作目录.

然后,您可以使用以下内容将"报告"附加到该报告:

Path.Combine(string, string):

Dim reportsFolder As String
reportsFolder = Path.Combine(Directory.GetCurrentDirectory(), "Reports")
Run Code Online (Sandbox Code Playgroud)


小智 6

Dim path As String = AppDomain.CurrentDomain.BaseDirectory
'replace \bin\Debug\ the part of the path you dont want  with part you do want
Dim path1 As String = path.Replace("\bin\Debug\", "\htmlFiles\")
Run Code Online (Sandbox Code Playgroud)