473,498 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Available Drive Letter

I am making a program for work that Maps to different hmi's (human - machine
interface) computers and makes a backup of the files we currently use in
them. It then unmaps the drives. I have a function that gets the first
available drive starting with Z and working backwords from thier. This
function works well in vb2005 but our work pc's only have .net framework
1.1.4322 so I need to change it to work with vb2003. Please help me with my
problem.

The following is the code I am currently using for this.

Public Function GetDriveLetter()
Dim intAlpha As Integer
Dim strAlpha As String
Dim boolDriveExists As Boolean
Dim myDrives As DriveInfo() = DriveInfo.GetDrives()
strAlpha = "ZYXWVUTSRQPONMLKJIHGFEBDA"
For intAlpha = 1 To Len(strAlpha)
boolDriveExists = False
GetDriveLetter = Mid(strAlpha, intAlpha, 1) & ":"
For Each d As DriveInfo In myDrives
If d.Name = CStr(GetDriveLetter & "\") Then
boolDriveExists = True
End If
Next
If boolDriveExists = False Then
Exit Function
End If
Next
End Function

Any help would be appreciated,
Dave Marden
Sep 3 '07 #1
2 3224
Dave,

http://dotnet.mvps.org/dotnet/code/f...tem/#DriveType

Cor

"Dave Marden" <ne*******@mardenfamily.comschreef in bericht
news:Oh**************@TK2MSFTNGP04.phx.gbl...
>I am making a program for work that Maps to different hmi's (human -
machine interface) computers and makes a backup of the files we currently
use in them. It then unmaps the drives. I have a function that gets the
first available drive starting with Z and working backwords from thier.
This function works well in vb2005 but our work pc's only have .net
framework 1.1.4322 so I need to change it to work with vb2003. Please help
me with my problem.

The following is the code I am currently using for this.

Public Function GetDriveLetter()
Dim intAlpha As Integer
Dim strAlpha As String
Dim boolDriveExists As Boolean
Dim myDrives As DriveInfo() = DriveInfo.GetDrives()
strAlpha = "ZYXWVUTSRQPONMLKJIHGFEBDA"
For intAlpha = 1 To Len(strAlpha)
boolDriveExists = False
GetDriveLetter = Mid(strAlpha, intAlpha, 1) & ":"
For Each d As DriveInfo In myDrives
If d.Name = CStr(GetDriveLetter & "\") Then
boolDriveExists = True
End If
Next
If boolDriveExists = False Then
Exit Function
End If
Next
End Function

Any help would be appreciated,
Dave Marden
Sep 4 '07 #2
Dave,

http://dotnet.mvps.org/dotnet/code/f...tem/#DriveType

Cor

"Dave Marden" <ne*******@mardenfamily.comschreef in bericht
news:Oh**************@TK2MSFTNGP04.phx.gbl...
>I am making a program for work that Maps to different hmi's (human -
machine interface) computers and makes a backup of the files we currently
use in them. It then unmaps the drives. I have a function that gets the
first available drive starting with Z and working backwords from thier.
This function works well in vb2005 but our work pc's only have .net
framework 1.1.4322 so I need to change it to work with vb2003. Please help
me with my problem.

The following is the code I am currently using for this.

Public Function GetDriveLetter()
Dim intAlpha As Integer
Dim strAlpha As String
Dim boolDriveExists As Boolean
Dim myDrives As DriveInfo() = DriveInfo.GetDrives()
strAlpha = "ZYXWVUTSRQPONMLKJIHGFEBDA"
For intAlpha = 1 To Len(strAlpha)
boolDriveExists = False
GetDriveLetter = Mid(strAlpha, intAlpha, 1) & ":"
For Each d As DriveInfo In myDrives
If d.Name = CStr(GetDriveLetter & "\") Then
boolDriveExists = True
End If
Next
If boolDriveExists = False Then
Exit Function
End If
Next
End Function

Any help would be appreciated,
Dave Marden
Sep 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
7167
by: jenny | last post by:
Hi, I am trying to find a VB way that would create a folder on all existing drives - the folder name would be the same on each drive. ie c:\backup, d:\backup, etc. But the folders would only be...
0
3207
by: BK Drake | last post by:
I am trying to assign a drive letter to a hidden partition. I have a hard drive that has 2 paritions - a system and a data partition. When I retore with an image the system drive the data drive...
0
2477
by: john doe | last post by:
How can I use WMI or a WqlObjectQuery to find the hard drive letter of the physical drive location index. For example the following code will give me the physical drive location:...
7
24117
by: jimdscudder | last post by:
How can I use WMI or a WqlObjectQuery to find the hard drive letter of the physical drive location index. For example the following code will give me the physical drive location:...
4
25104
by: sanjana | last post by:
hi i m using the win32_diskdrive class for detecting a memory card insertion and removal..and this class detects memory card(sd card..etc) insertion removal from the device the deviceid...
2
8163
by: Kavitha | last post by:
Hi , Can any one tel me how to create a virtual drive in C#( similar to Gmail Virtual drive).Also tell me what interfaces could be used to create the same. Thanks in Advance Kavitha
4
3455
by: Jim Carlock | last post by:
function CreateMyDataBaseFile($FQFN, $UID, $PW) { $db = "sqlite:" . $FQFN; $sql = "CREATE TABLE Customers(name1 TEXT, name2 TEXT);"; $dbh = new PDO($db, $UID, $PW); $dbh->exec($sql); $dbh =...
4
9119
by: Luc The Perverse | last post by:
Hi - I have very little C# programming experience. I am making a software product which calls for an interface almost identical to Windows Explorer - and I wondered if mounting a "virtual drive"...
3
3061
by: Killer42 | last post by:
Hi all. Summary Plugging flash drive into work PC, no drive appears. Details First of all, I have searched TheScripts for an answer. The closest I found was this article which covered...
2
2656
by: | last post by:
Is it possible to programmatically find the next available drive letter that could be used to map a file share? Or is my best bet to just call net use and parse the output? Thanks in...
0
7125
marktang
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,...
0
7002
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...
0
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6885
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...
0
7379
tracyyun
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...
0
5462
agi2029
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,...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.