Browse for a file on a network

I have created a program that relies on the utilisation of another file. I have currently got a form that allows you so select the drive, directory and then file, using the respective VB controls and synchronisation between them. This works well, however I would like to be able to browse through the entire network stucture to select the file. Any ideas on how to do this. Im sure it's trivial, I just dont know how!
Ice123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
Hi Ice123,

The simplest solution is to use the common dialog control. Add this component to your project and place an instance on the form. You can then use the .ShowOpen method to display the standard windows open file dialog and the .FileName property returns the selected file and full path.

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
TomLaw1999Commented:
Tims method is the way to do it however if you would prefer to handle this programatically you can enter a path to the desired file, for example

\\Servername\c\Adirectory\Afile
0
Ice123Author Commented:
Thanks TomLaw1999 - I already have that option so any path can be entered.

TimCottee:

Can you please give me an example, I have never dealt with common dialog control before, and am a reasonably new programmer.

thanks.
0
TimCotteeHead of Software ServicesCommented:
Ok, in your IDE, choose Project, Components; scroll down till you get to Microsoft Common Dialog Control and check the box next to it to add to your toolbox. Then place this new control on your form. In your code (perhaps for a command button) use:

Private Sub Command1_Click()
    With CommonDialog1
        On Error GoTo errHandler
        .CancelError = True
        .ShowOpen
        MsgBox "File selected was : " & .FileName
    End With
    Exit Sub
   
errHandler:
    If Err.Number = cdlCancel Then
        MsgBox "The selection process was cancelled"
    Else
        MsgBox "Another error occurred"
    End If
End Sub


This will either display the selected file, a message saying you cancelled or that a different error occurred.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dang123Commented:
Listening.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.