By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,827 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,827 IT Pros & Developers. It's quick & easy.

how to open files only in drive "e:\"

P: n/a
excuse me, may i ask on how to open files only in drive "e:\" (which is my
usb port for flash drives) using openfiledialog? because in the
openfiledialog, even when i set my initialdirectory to drive "e:\", people
can still browse other drives(drive c, d, etc. )

so for example, when they insert their flash drives, then they open the
openfiledialog, how can i make an error trap on how to let them open files
only in their flash drives which is drive "e:\"? and when they try to open
files from drive c or other drives, a msgbox will appear like "sorry, you can
open files only in drive e".

can anyone post a code for this? thanks!!

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200801/1

Jan 12 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"jabslim via DotNetMonster.com" <u40064@uwewrote in
news:7e1b0c5ee7844@uwe:
so for example, when they insert their flash drives, then they open
the openfiledialog, how can i make an error trap on how to let them
open files only in their flash drives which is drive "e:\"? and when
they try to open files from drive c or other drives, a msgbox will
appear like "sorry, you can open files only in drive e".

can anyone post a code for this? thanks!!
I don't think this is possible with the standard open file dialog box...
you'll need to create your own dialog box which shouldn't be too hard to
do.

--
sp**********@rogers.com (Do not e-mail)
Jan 12 '08 #2

P: n/a
On Jan 12, 6:17 pm, "jabslim via DotNetMonster.com" <u40064@uwe>
wrote:
excuse me, may i ask on how to open files only in drive "e:\" (which is my
usb port for flash drives) using openfiledialog? because in the
openfiledialog, even when i set my initialdirectory to drive "e:\", people
can still browse other drives(drive c, d, etc. )

so for example, when they insert their flash drives, then they open the
openfiledialog, how can i make an error trap on how to let them open files
only in their flash drives which is drive "e:\"? and when they try to open
files from drive c or other drives, a msgbox will appear like "sorry, you can
open files only in drive e".

can anyone post a code for this? thanks!!

--
Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200801/1
Maybe you can disallow users after selecting file with that code:

If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
If OpenFileDialog1.FileName.StartsWith("E:\") = False Then
MsgBox("Nope")
Else
'Do what you want
End If
End If
Hope this helps
Jan 12 '08 #3

P: n/a
Hi,

It's possible using Dialog Workshop.NET dialog components.
Special CaOpenFileDialog component replaces OpenFileDialog component and
allows you to restrict folder change in open/save dialogs. It's possible if
you add just two event handlers. See RestrictingFolderchange sample provided
in the Dialog Workshop.NET evaluation package. Also many other powerful
features are available ("docking" your own WinForm to the dialog window,
etc.).

Please visit http://www.componentage.com for details.

Hope it helps.
Alex Petrov

"jabslim via DotNetMonster.com" <u40064@uweсообщил/сообщила в новостях
следующее: news:7e1b0c5ee7844@uwe...
excuse me, may i ask on how to open files only in drive "e:\" (which is my
usb port for flash drives) using openfiledialog? because in the
openfiledialog, even when i set my initialdirectory to drive "e:\", people
can still browse other drives(drive c, d, etc. )

so for example, when they insert their flash drives, then they open the
openfiledialog, how can i make an error trap on how to let them open files
only in their flash drives which is drive "e:\"? and when they try to open
files from drive c or other drives, a msgbox will appear like "sorry, you
can
open files only in drive e".

can anyone post a code for this? thanks!!

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200801/1
Jan 12 '08 #4

P: n/a
thanks for your help guys! i got the info i wanted!!

kimiraikkonen wrote:
>On Jan 12, 6:17 pm, "jabslim via DotNetMonster.com" <u40064@uwe>
wrote:
>excuse me, may i ask on how to open files only in drive "e:\" (which is my
usb port for flash drives) using openfiledialog? because in the
[quoted text clipped - 11 lines]
>--
Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/200801/1

Maybe you can disallow users after selecting file with that code:

If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
If OpenFileDialog1.FileName.StartsWith("E:\") = False Then
MsgBox("Nope")
Else
'Do what you want
End If
End If

Hope this helps
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200801/1

Jan 13 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.