Drive Letter Property 
Author Message
 Drive Letter Property

I have successfully used the DriveLetter property to get a list of the local
Dim fs, d, dc
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set dc = fs.Drives
For Each d In dc
    If d.DriveType = 2 Then
         k = k + 1
        strLocalDrive(k) = d.driveletter & ":\"
    End If

It works great!

Then I needed to know if a network share was associated with the right
letter. I used vb help and found the following sub:

Sub ShowDriveLetter(drvpath)
    Dim fs, d, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set d = fs.GetDrive(fs.GetDriveName(drvpath))
    s = "Drive " & d.driveletter & ": - "
    s = s & d.VolumeName & vbCrLf
    s = s & "Free Space: " & FormatNumber(d.FreeSpace / 1024, 0)
    s = s & " Kbytes"
    MsgBox s
    Debug.Print d.driveletter
End Sub

I used it in my code as follow:
Dim fs, d, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set d = fs.GetDrive(fs.GetDriveName("\\smb\Uhome"))
    s = d.driveletter

s does not return "N" as it should, but returns an empty string. Why?

Thanks for your help in advance.

Tue, 25 Oct 2005 02:51:10 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Drive letter driving me crazy!

2. Retrieving drive letter for user's cd-rom drive

3. Determining drive letter assigned to floppy drive?

4. local drive letter <> drive share name

5. get mapped drive letter from UNC path

6. Specifying server directory without mapped drive letter

7. Acc2.0:Getting CD drive unit letter

8. CD drive letter determination

9. HowTo: Get UNC path based on a drive letter

10. Finding CD-ROM Drive Letter

11. CD-ROM drive letter?

12. Drive Letter Assignment


Powered by phpBB® Forum Software