Results 1 to 8 of 8

Thread: Using Server.MapPath in windows app

  1. #1

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366

    Question Using Server.MapPath in windows app

    I am trying to write a windows application .exe that uses Server.MapPath as I need to get the folder of a virtual directory.

    I have added the System.Web reference to my project, but it still tells me that 'Server' cannot be found.

    How can I get the path of a virtual directory in my vb.net windows app?

    Greg

  2. #2
    Addicted Member Rockhopper's Avatar
    Join Date
    Aug 2003
    Location
    Cape Town, South Africa
    Posts
    199
    Instead of server.mappath, rather try Application.StartupPath

    Application.StartupPath will reference you to the project file that you are working in.

    For example, if you are looking for a file in your bin folder:

    strDatabase = Application.StartupPath & "\bin\Database.mdb"

    hope i understood your question properly and are of some assistance.
    If the facts don't fit the theory, change the facts. --Albert Einstein

  3. #3

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    No,

    The problem is I need to detect 2 virtual directories on the PC. I need to get their physical path.

    Application.Startup path won't help me because the directories will be elsewhere on the PC than the current application.

  4. #4
    Addicted Member Rockhopper's Avatar
    Join Date
    Aug 2003
    Location
    Cape Town, South Africa
    Posts
    199
    ok, sorry for that.

    i think i have a solution, but first... do you know the name of the folder or file that you are looking for?
    If the facts don't fit the theory, change the facts. --Albert Einstein

  5. #5
    Addicted Member Rockhopper's Avatar
    Join Date
    Aug 2003
    Location
    Cape Town, South Africa
    Posts
    199
    Ok, i have an idea. i've never tried it, but look in your MSDN search for IsolatedStorageFile.GetDirectoryNames

    you can search for virtual directory and file paths... it's a nice little search.

    good luck, let me know if it helps
    If the facts don't fit the theory, change the facts. --Albert Einstein

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The problem is that the windows app has no reference to the web context and thus no way of knowing which web its in (because its not in one). I'm assuming you are calling this exe from within website code. If so then pass the paths in as a commandline parameter then you can use Server.MapPath in the page and pass that info along.

  7. #7

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    Originally posted by Rockhopper
    ok, sorry for that.

    i think i have a solution, but first... do you know the name of the folder or file that you are looking for?
    Yeah, the first folder name is Officium, the second folder name is OfficiumData

  8. #8

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    I was thinking of writing an app that starts from C: and checks if the folder exists, if not, then check if it exists on D: etc.

    Then if I find it, I write the value to a .txt file or database for later reference.

    Do you think this is a good idea?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width