CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Jan 2012
    Posts
    35

    How check if file exists on Network cmptr

    I am using VB5. I know how to use Dir and FSO to check if a file exists on my computer, but how do you check if a file exists on a "Network" computer?? I've checked Google but can't find an answer.

    Thanks for your help.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How check if file exists on Network cmptr

    Need to log in, first. NET USE /? will show the commands needed.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jan 2012
    Posts
    35

    Re: How check if file exists on Network cmptr

    I am using VB5.

    I don't understand your post????

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How check if file exists on Network cmptr

    You check on the network in the same fashion as you would locally. You must either be logged in on your system with a user ID and password that is valid on the target computer or you must have connected to it with a userid and password that grants access.

    If it is a mapped drive then you can just use the mapped drive letter just like you would for yoru local drive. If it is not mapped then you would need to use a UNC path as in \\PCName\DriveName\path\file
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jan 2012
    Posts
    35

    Re: How check if file exists on Network cmptr

    The documentation for "Dir" says file string you search for must begin with either a letter or number!

    That's the reason "\\Server\File Folder\Myfile.txt" doesn't work for me using Dir and I assume why it doesn't work for me using FSO.

    I'm still stumped!!

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How check if file exists on Network cmptr

    NET USE /? BEFORE your type a drive letter. MAP the drive, first.....
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How check if file exists on Network cmptr

    Dir() works fine with UNC path names as long as you have access to the drive. If you would have to provide a different user id and/or password then you may run into issues unless you connect to the drive first via Net Use or other option.

    This code returns the first zip file in the archive folder of my server under VB6. I assume it will work under VB5 but can't say for sure. If not then you need to ditch VB5 and move to something newer. Most of us quit using VB5 over 10 years ago.

    Code:
    MsgBox Dir("\\Ultra-955\Raid-mirror\archives\*.zip")
    Last edited by DataMiser; February 4th, 2012 at 07:23 PM.
    Always use [code][/code] tags when posting code.

  8. #8
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How check if file exists on Network cmptr

    Quote Originally Posted by DexterRose View Post
    The documentation for "Dir" says file string you search for must begin with either a letter or number!

    That's the reason "\\Server\File Folder\Myfile.txt" doesn't work for me using Dir and I assume why it doesn't work for me using FSO.

    I'm still stumped!!
    btw What do you mean when you say it doesn't work? You'll find that you should be descriptive when you are talking about an issue. Doesn't work could mean almost anything when talking about programming.
    Always use [code][/code] tags when posting code.

  9. #9
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    Re: How check if file exists on Network cmptr

    Make sure you do have access to the server

    Click on Start
    Click on Run
    key \\Server - PRESS ENTER

    Do You see the server directory ?
    Is the Folder you want Shared ?
    Did it ask for User Name and Password ? (This is probably your problem)
    - supply this and Dir will work

  10. #10
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How check if file exists on Network cmptr

    That doesn't help the VB6 issue, George
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  11. #11
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How check if file exists on Network cmptr

    What VB6 Issue?

    VB6 Dir() function works fine with UNC or mapped paths. If you have connected to the drive with Net Use or other method already then there should be no issue.
    Always use [code][/code] tags when posting code.

  12. #12
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    Re: How check if file exists on Network cmptr

    I don't think he has a VB6 issue (yet ...)

    I think he's not getting to first base - connecting to the server

  13. #13
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How check if file exists on Network cmptr

    Quote Originally Posted by George1111 View Post
    I don't think he has a VB6 issue (yet ...)
    He is using VB5
    Always use [code][/code] tags when posting code.

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

Featured