Search code examples
vb.netdirectoryprojects-and-solutionsstartup

How do I get path of the Directory inside my WinForm app project


I have a directory named reports inside my winform project in .net. My project name is AccountingReports and inside that Directory reports exists. So i need the way to access this path via code. In Asp.net we use Request.PhysicalApplicationPath property. So is there any method or property exists that will give me the root of my project


Solution

  • You can use:

    Directory.GetCurrentDirectory

    Gets the current working directory of the application.

    You can then append "Reports" to that using the following:

    Path.Combine(string, string):

    Dim reportsFolder As String
    reportsFolder = Path.Combine(Directory.GetCurrentDirectory(), "Reports")