Results 1 to 7 of 7

Thread: App.Path and networks?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Posts
    29

    App.Path and networks?

    Hello,

    I was hoping that a application which reads files using App.Path (i.e. files are stored relative to .exe) would work over a network but apparently not.

    Apparently it works OK on the server (as expected) but when a client machine runs the .exe (and it's just running the .exe on the server whcih has been shared), it cannot access the files. I cant check this myself but presumably something is going wrong with App.Path when used over a network? But the .exe being run on the client is located on the server so cant see why App.Path would change!

    Am I overlooking something or is it a case of something being wrong with App.Path on a network?

    Thanks

  2. #2
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245

    Re: App.Path and networks?

    Originally posted by TomJones
    Hello,

    I was hoping that a application which reads files using App.Path (i.e. files are stored relative to .exe) would work over a network but apparently not.

    Apparently it works OK on the server (as expected) but when a client machine runs the .exe (and it's just running the .exe on the server whcih has been shared), it cannot access the files. I cant check this myself but presumably something is going wrong with App.Path when used over a network? But the .exe being run on the client is located on the server so cant see why App.Path would change!

    Am I overlooking something or is it a case of something being wrong with App.Path on a network?

    Thanks
    Can you give us an example of what it returns? My guess is the UNC, in which case you'll need to ensure that the proper permissions are on the network share.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  3. #3
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    App.Path will return you the trailing slash if it's working in a shared folder.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    You can use this function to be sure that no matter if it's a shared folder, a root folder (of a harddrive) or whatever. They will all retrieve the path without the trailing slash:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     MsgBox AppPath
    5. End Sub
    6.  
    7. Public Function AppPath() As String
    8.     AppPath = App.Path
    9.     If Right$(App.Path, 1) = "\" Then
    10.         AppPath = Left$(AppPath, Len(AppPath) - 1)
    11.     End If
    12. End Function
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Originally posted by Mc Brain
    App.Path will return you the trailing slash if it's working in a shared folder.
    Ah hah, good point! Another option is to use the following:

    MsgBox IIF(Right(App.Path, 1) = "\", Left(App.Path, Len(App.Path) -1), App.Path)
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  6. #6
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Originally posted by Sheppe
    Ah hah, good point! Another option is to use the following:

    MsgBox IIF(Right(App.Path, 1) = "\", Left(App.Path, Len(App.Path) -1), App.Path)
    It is!!.... If you're going to use it like only once in the whole project. Even if you copy & paste that... is a pain in the a... there to look for it to copy & paste, or even re-writting the whole line multiple times. Best approach.... create a function (like I did), and add the code you like best.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  7. #7
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Originally posted by Mc Brain
    It is!!.... If you're going to use it like only once in the whole project. Even if you copy & paste that... is a pain in the a... there to look for it to copy & paste, or even re-writting the whole line multiple times. Best approach.... create a function (like I did), and add the code you like best.
    Agreed. There's no performance gain in doing it either way, so a function would make more sense if for no other reason than being easier to look at.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

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