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

  • Thread starter jabslim via DotNetMonster.com
  • Start date
J

jabslim via DotNetMonster.com

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!!
 
G

Guest

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.
 
K

kimiraikkonen

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!!

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
 
A

Alex Petrov

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
 
J

jabslim via DotNetMonster.com

thanks for your help guys! i got the info i wanted!!


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]
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top