C# App: application.startuppath

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • getgagan
    New Member
    • Dec 2007
    • 10

    #1

    C# App: application.startuppath

    how to find Main folder where bin folder exists using application.sta rtuppath in c#

    IF
    application.sta rtuppath=D:\Tes t\ThreadExample \DnsLookup\DnsL ookup\bin\Debug

    Then i need to find the folder exactly like :
    D:\Test\ThreadE xample\DnsLooku p\DnsLookup

    how ??
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    There is no function provided by .Net framework to get the application path
    as mentioned by you. But you can do it this way :

    e.g.
    yourpath = "D:\Test\Thread Example\DnsLook up\DnsLookup\bi n\Debug"
    path=yourpath.S ubstring(1, yourpath.IndexO f("\bin"))


    Originally posted by getgagan
    how to find Main folder where bin folder exists using application.sta rtuppath in c#

    IF
    application.sta rtuppath=D:\Tes t\ThreadExample \DnsLookup\DnsL ookup\bin\Debug

    Then i need to find the folder exactly like :
    D:\Test\ThreadE xample\DnsLooku p\DnsLookup

    how ??

    Comment

    • demaus
      New Member
      • Dec 2007
      • 6

      #3
      This depends on which Framework you are using. If you are using VS2005 then you should have the ability to get the directory path with:

      Code:
       
      My.Application.Info.DirectoryPath
      Haven't tried this in C# though so maybe it won't work for you.

      Comment

      • getgagan
        New Member
        • Dec 2007
        • 10

        #4
        We can do Like this as in above reply


        But I forget, I hv used something like this "\.." to find parent folder of application.sta rtuppath. and "\.. \.." to get parent of parent(applicat ion.startuppath ). but now this is not working as due to syntex error

        Can anyone help ??

        Comment

        • shweta123
          Recognized Expert Contributor
          • Nov 2006
          • 692

          #5
          Hi,

          What code have you written and what is the error that you are getting?

          Originally posted by getgagan
          We can do Like this as in above reply


          But I forget, I hv used something like this "\.." to find parent folder of application.sta rtuppath. and "\.. \.." to get parent of parent(applicat ion.startuppath ). but now this is not working as due to syntex error

          Can anyone help ??

          Comment

          • Shashi Sadasivan
            Recognized Expert Top Contributor
            • Aug 2007
            • 1435

            #6
            The full directory path where your exe file is run from will be determined by

            AppDomain.Curre ntDomain.BaseDi rectory

            (I have been using this)
            cheers

            Comment

            Working...