How can I set my openfiledialog just to open My Network Places(shared) Local Directory not included.
If you have the sample code it'll be nice
thanks
How can I set my openfiledialog just to open My Network Places(shared) Local Directory not included.
If you have the sample code it'll be nice
thanks
Browse Network place only, howto?
V.E
I'm not sure what the deal is with you not seeing your local machine in the network neighborhood - my computer shows up when I browse my network.
But if you're trying to access a shared folder on the local machine you should be able to access it directly using the local path.
Evan Mulawski
Do you have other version of code for Smartdevice that can only browse the shared folder, I've copy paste your code to Smartdevice app and it didnt work
drives = System.IO.DriveInfo.GetDrives
on SmartDevice, "DriveInfo" is not member of System.IO
JIM.H.
Based on other threads about modifing the default behavior of the FileDialogs I would say that you can't exactly do this (and if you could there'd be good reasons not to).
I think you're two options are to either create your own dialog, or force the user to select a network folder by not accepting any other choice. Here's a code snipit that will start the dialog in the "My Network Places" folder and then force the user to try again if they select a non-network location:
Dim NetDrives As New List(Of String)
Dim drives() As System.IO.DriveInfo
drives = System.IO.DriveInfo.GetDrives
For Each dr As System.IO.DriveInfo In drives
If dr.DriveType = IO.DriveType.Network Then
NetDrives.Add(dr.Name)
End If
Next
Dim dir As String = System.IO.Directory.GetParent(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal)).FullName
dir &= "\NetHood"
Me.OpenFileDialog1.InitialDirectory = dir
Me.OpenFileDialog1.FileName = String.Empty
While Me.OpenFileDialog1.FileName = String.Empty
If Me.OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim IsValid As Boolean = False
If Me.OpenFileDialog1.FileName.StartsWith("\\") Then
IsValid = True
Else
Dim drl As String = System.IO.Path.GetPathRoot(Me.OpenFileDialog1.FileName)
If NetDrives.Contains(drl) Then
IsValid = True
End If
End If
If Not IsValid Then
MessageBox.Show("This does not appear to be a valid network folder. Please try again.")
Me.OpenFileDialog1.FileName = ""
End If
Else
Exit Sub
End If
End While
This should give you the desired result without having to code your own dialog.
HTH, GL
Carl Tribble
Hi, feby,
I don't believe there's any way to restrict the OFD to open just network resources (much less with the further restriction of just the network resources specified in My Network Places). You'd likely have to build your own dialog to do this.
--Matt--*
Hemant Kumar
Sorry, I'm not experienced with SmartDevice application development.
The part of the code that uses the DriveInfo class is only to handle mapped network drives. If there won't be any mapped drives then you can just skip the part of the code that is failing.
r3ganc
kimble..My computer doesnt appear on openfile dialog!
I open "My Network" on openfiledialog, click "Entire Network", click "Microsoft Windows Network", click <group name>, and then my computer not show up
How can I view my shared folder when I can't find my computer. How about you does your computer show up
Fusion1224
I modified your code like this :
Me
.OpenFileDialog1.InitialDirectory = "\\ComputerName" -->> the difference Me.OpenFileDialog1.FileName = String.Empty While Me.OpenFileDialog1.FileName = String.Empty If Me.OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then Dim IsValid As Boolean = False If Me.OpenFileDialog1.FileName.StartsWith("\\") ThenIsValid =
TrueMap4.Width = 3200
Map4.Height = 2200
SimpleLoc.Text = (OpenFileDialog1.FileName)
Map4.Image =
New Bitmap(OpenFileDialog1.FileName) Else Dim drl As String = System.IO.Path.GetPathRoot(Me.OpenFileDialog1.FileName) If NetDrives.Contains(drl) ThenIsValid =
True End If End If If Not IsValid ThenMessageBox.Show(
"This does not appear to be a valid network folder. Please try again.") Me.OpenFileDialog1.FileName = "" End If Else Exit Sub End If End While