?
Solved

specify or browse a folder on a network drive

Posted on 1998-11-22
7
Medium Priority
?
203 Views
Last Modified: 2010-05-03
I would like to specify a folder on a network drive in a visual basic program I am writing. I cannot use a common dialog because the folder may not have any files in it, or I may want to create a new folder on the network drive, with no files in it. I would like to use an interface similar to a common dialog open form or network neighborhood. Any help would be appreciated.
0
Comment
Question by:cliff_martin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 1446191
Umm, you *can* use the CommonDialog. It just requires the filename field to be non-blank before the OK button will work. If the user is in an empty directory they can just type X or something and click [OK] and it will return without a problem unless you've got the FileMustExist flag set. If you enable [Cancel] error trap I *think* it will return whatever directory the user has changed to in .FileName

Alternative is to use drive and directory boxes or "roll your own" common dialog box.

M

0
 

Author Comment

by:cliff_martin
ID: 1446192
The common dialog open does not work well. I try to select a directory and end up selecting the directory above it because it I did not click on the whitespace to select directory (if you can follow that, I am impressed). What I am trying to say is that while it does work, it can be confusing to the user. I would be interested in any help in "rolling my own" as you say, though. thanks
0
 
LVL 3

Expert Comment

by:jjbyers
ID: 1446193
Do you want to connect to a network drive or just get a path to a drive already connected?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:cliff_martin
ID: 1446194
I want to be able to browse all available network shares, not just mapped drives.
0
 
LVL 3

Accepted Solution

by:
jjbyers earned 60 total points
ID: 1446195
This is the code I use to show the explorer map/disconnect drive dialog box.

Public Const RESOURCETYPE_DISK = &H1

Public Declare Function WNetConnectionDialog Lib "mpr.dll" _
   (ByVal hwnd As Long, ByVal dwType As Long) As Long
   
Public Declare Function WNetDisconnectDialog Lib "mpr.dll" _
   (ByVal hwnd As Long, ByVal dwType As Long) As Long

Public Sub ShowMapDriveDlg(pfrmParent As Form)
'*********************************************************
'* Purpose: Shows the networking map drive letter dialog
'*
'* Input Parameters: pfrmParent - Parent form name
'*
'* Returns: None
'*
'* Called Routines: None
'*********************************************************
  'If the function succeeds, the return value is
  'NO_ERROR (0). If the user cancels out of the
  'dialog box, it is &HFFFFFFFF.
             
  'Passing the form as the hwnd displays the
  'dialog modally to that form.  Pass 0& to
  'make the parent the desktop.
 
  'Setup error trapping
  On Error GoTo MapDrive_Error
 
  Call WNetConnectionDialog(pfrmParent.hwnd, RESOURCETYPE_DISK)
 
  'No Error Exit
  Exit Sub
 
MapDrive_Error:
  'Show Error
  MsgBox "Error in ShowMapDriveDlg of " & Err.Description & " " & Err.Number, vbOKOnly + vbCritical, App.ProductName
End Sub
     
Public Sub ShowDisconnectDriveDlg(pfrmParent As Form)
'*********************************************************
'* Purpose: Shows the networking Disconnect drive dialog
'*
'* Input Parameters: pfrmParent - Parent form name
'*
'* Returns: None
'*
'* Called Routines: None
'*********************************************************
  'If the function succeeds, the return value is
  'NO_ERROR (0). If the user cancels out of the
  'dialog box, it is &HFFFFFFFF.
             
  'Passing the form as the hwnd displays the
  'dialog modally to that form.  Pass 0& to
  'make the parent the desktop.
 
  'Setup error trapping
  On Error GoTo DisconnectDrive_Error
 
  Call WNetDisconnectDialog(pfrmParent.hwnd, RESOURCETYPE_DISK)
 
  'No Error Exit
  Exit Sub
 
DisconnectDrive_Error:
  'Show Error
  MsgBox "Error in ShowDisconnectDriveDlg of " & Err.Description & " " & Err.Number, vbOKOnly + vbCritical, App.ProductName
End Sub

0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1446196
Bought This Question.
0
 

Expert Comment

by:soyapi
ID: 3335252
You just can map\connect to the other computer, but not on NT Server, I got Access Deny though I supply the right password, still access deny.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question