This might be a pipe dream, but here goes...
I'm writing an application many users will be working on and saving
files to USB flash drives. When they click the save button, I would like
to have the default save path be the flash drive, if one exists. The
best solution I can thing of is to assume the drive will be E:\ and put
that in a Try/Catch to have that be the default path.
Does anyone know of a better solution that this can be accomplished in
VB.NET?
(I'm using VB.NET 2005)
Thanks,
Dustin 5 3923
Hi Dustin,
Not a pipe dream at all. In the System.IO namespace there are classes for
enumerating available drives on the machine. You can check the properties
of each drive and I think you should be able to tell from those properties
whether it's a removable drive. Failing that, start looking into the WMI
classes as they will undoubtedly have the power to determine the exact spec
of all available drives on the machine.
Cheers,
Alex Clark
"Dustin Davis" <du**********@gmail.com> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl... This might be a pipe dream, but here goes...
I'm writing an application many users will be working on and saving files to USB flash drives. When they click the save button, I would like to have the default save path be the flash drive, if one exists. The best solution I can thing of is to assume the drive will be E:\ and put that in a Try/Catch to have that be the default path.
Does anyone know of a better solution that this can be accomplished in VB.NET?
(I'm using VB.NET 2005)
Thanks, Dustin
Wow - Awesome, thanks for the info!
Alex Clark wrote: Hi Dustin,
Not a pipe dream at all. In the System.IO namespace there are classes for enumerating available drives on the machine. You can check the properties of each drive and I think you should be able to tell from those properties whether it's a removable drive. Failing that, start looking into the WMI classes as they will undoubtedly have the power to determine the exact spec of all available drives on the machine.
Cheers, Alex Clark
"Dustin Davis" <du**********@gmail.com> wrote in message news:O2**************@TK2MSFTNGP12.phx.gbl... This might be a pipe dream, but here goes...
I'm writing an application many users will be working on and saving files to USB flash drives. When they click the save button, I would like to have the default save path be the flash drive, if one exists. The best solution I can thing of is to assume the drive will be E:\ and put that in a Try/Catch to have that be the default path.
Does anyone know of a better solution that this can be accomplished in VB.NET?
(I'm using VB.NET 2005)
Thanks, Dustin
Thanks again Alex. It works great. Here's the code in case anyone else
is interested:
' Find the first removable storage device and make this the initial
' directory if it exists
Dim allDrives() As IO.DriveInfo = IO.DriveInfo.GetDrives()
Dim d As IO.DriveInfo
For Each d In allDrives
If d.IsReady = True AndAlso d.DriveType = IO.DriveType.Removable Then
Me.SaveFileDialog1.InitialDirectory = d.Name
End If
Next
Alex Clark wrote: Hi Dustin,
Not a pipe dream at all. In the System.IO namespace there are classes for enumerating available drives on the machine. You can check the properties of each drive and I think you should be able to tell from those properties whether it's a removable drive. Failing that, start looking into the WMI classes as they will undoubtedly have the power to determine the exact spec of all available drives on the machine.
Cheers, Alex Clark
"Dustin Davis" <du**********@gmail.com> wrote in message news:O2**************@TK2MSFTNGP12.phx.gbl... This might be a pipe dream, but here goes...
I'm writing an application many users will be working on and saving files to USB flash drives. When they click the save button, I would like to have the default save path be the flash drive, if one exists. The best solution I can thing of is to assume the drive will be E:\ and put that in a Try/Catch to have that be the default path.
Does anyone know of a better solution that this can be accomplished in VB.NET?
(I'm using VB.NET 2005)
Thanks, Dustin
Thank you Dustin for the code. (I think you need an exit for, if you
mean to catch the first one :)
But actually, I have another problem, I have been trying this code om
my 2 usb drives (Avixe 1Gb, Arcdisk 4Gb). Strangely the Arcdisk, is not
reported as "Removable" in the DriveInfo but as "Fixed". Strange eh?
Does anyone have an explanation for that. One difference beetween the 2
USB drives, apart the size, is that I have formatted Arcdisk as NTFS
while the other is FAT. Can this be a reason ?? Or is this a bug of
DriveInfo.GetDrives ?
Dustin Davis ha scritto: Thanks again Alex. It works great. Here's the code in case anyone else is interested:
' Find the first removable storage device and make this the initial ' directory if it exists Dim allDrives() As IO.DriveInfo = IO.DriveInfo.GetDrives() Dim d As IO.DriveInfo For Each d In allDrives If d.IsReady = True AndAlso d.DriveType = IO.DriveType.Removable Then Me.SaveFileDialog1.InitialDirectory = d.Name End If Next
Alex Clark wrote: Hi Dustin,
Not a pipe dream at all. In the System.IO namespace there are classes for enumerating available drives on the machine. You can check the properties of each drive and I think you should be able to tell from those properties whether it's a removable drive. Failing that, start looking into the WMI classes as they will undoubtedly have the power to determine the exact spec of all available drives on the machine.
Cheers, Alex Clark
"Dustin Davis" <du**********@gmail.com> wrote in message news:O2**************@TK2MSFTNGP12.phx.gbl... This might be a pipe dream, but here goes...
I'm writing an application many users will be working on and saving files to USB flash drives. When they click the save button, I would like to have the default save path be the flash drive, if one exists. The best solution I can thing of is to assume the drive will be E:\ and put that in a Try/Catch to have that be the default path.
Does anyone know of a better solution that this can be accomplished in VB.NET?
(I'm using VB.NET 2005)
Thanks, Dustin
to**************@uniroma1.it wrote: Thank you Dustin for the code. (I think you need an exit for, if you mean to catch the first one :)
Acutally, I wanted the last one, since the first one will normally be
the A:\ drive.
I'm not sure why your other drive would say fixed. That is interesting! But actually, I have another problem, I have been trying this code om my 2 usb drives (Avixe 1Gb, Arcdisk 4Gb). Strangely the Arcdisk, is not reported as "Removable" in the DriveInfo but as "Fixed". Strange eh? Does anyone have an explanation for that. One difference beetween the 2 USB drives, apart the size, is that I have formatted Arcdisk as NTFS while the other is FAT. Can this be a reason ?? Or is this a bug of DriveInfo.GetDrives ?
Dustin Davis ha scritto:
Thanks again Alex. It works great. Here's the code in case anyone else is interested:
' Find the first removable storage device and make this the initial ' directory if it exists Dim allDrives() As IO.DriveInfo = IO.DriveInfo.GetDrives() Dim d As IO.DriveInfo For Each d In allDrives If d.IsReady = True AndAlso d.DriveType = IO.DriveType.Removable Then Me.SaveFileDialog1.InitialDirectory = d.Name End If Next
Alex Clark wrote: Hi Dustin,
Not a pipe dream at all. In the System.IO namespace there are classes for enumerating available drives on the machine. You can check the properties of each drive and I think you should be able to tell from those properties whether it's a removable drive. Failing that, start looking into the WMI classes as they will undoubtedly have the power to determine the exact spec of all available drives on the machine.
Cheers, Alex Clark
"Dustin Davis" <du**********@gmail.com> wrote in message news:O2**************@TK2MSFTNGP12.phx.gbl... This might be a pipe dream, but here goes...
I'm writing an application many users will be working on and saving files to USB flash drives. When they click the save button, I would like to have the default save path be the flash drive, if one exists. The best solution I can thing of is to assume the drive will be E:\ and put that in a Try/Catch to have that be the default path.
Does anyone know of a better solution that this can be accomplished in VB.NET?
(I'm using VB.NET 2005)
Thanks, Dustin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ray Lavelle |
last post by:
I have a utility I wrote which can backup/restore my database as well
as schedule backups. This has always worked pretty well except when I
try to backup to a USB Flash Disk. When I use one of...
|
by: Burl Stafford |
last post by:
Is it possible to install 2000 on a flash drive and then use the drive on a
laptop that only has 97 installed? I am not allowed to install 2000 on the
laptop, but I want to be able to do work with...
|
by: will.leighton |
last post by:
I am working on concept where I want to deliver web-based content and
functionality from a USB Flash drive for users who don't have access to
the Internet. The functionality includes personaliztion...
|
by: Putty |
last post by:
Is there such a thing as a special version of python that I can run
more efficiently from a flash drive? I'll be at college for hours
every day with hours of free time for the next few months, but...
|
by: Joe Cool |
last post by:
I know this is probably not the proper newsgroup to ask this question,
but I do not know which one is. And most of you guys here know a lot
about windows programming so I am taking a chance some...
|
by: ryancol |
last post by:
I have a couple usb 2.0 flash drives. I use them on either windows 2000 or windows XP. When I copy (drag and drop) a file folder to them such as a file folder with like 10 or 20 pictures in it the...
|
by: Chrisjc |
last post by:
<Excerpted from this thread>
All of these questions and answers are great. But it comes down to this I have seen this more than enough times to know better...
From my experience at home and as...
|
by: Salad |
last post by:
I was asked to get my daughter a flash drive. She needs to use it to
copy files to it so she can transfer the files at school to her desktop
at home.
I've never used one but I figure some of...
|
by: Daffydd |
last post by:
Hi all,
This one's driving me up a wall!
We have a small office network, Windows SBS 2003, nothing fancy - recently upgraded from an old Compaq running Novell. Back in the day we used the "F"...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |