Be the first user to complete this post

  • 0
Add to List

FileSystemObject : GetDriveName Method

Description: 

Returns drive name, corresponding to the file name.

Format : 

objectOfFileSystemObject. GetDriveName(filepath)

  • objectOfFileSystemObject : As the names says, it’s a FileSystemObject.
Arguments: 
  • filepath
    • Mandatory
    • Type:     String
    • filepath , whose parent drive to be return.

Function FnGetDriveName (strFilePath)
      Set fso = CreateObject("Scripting.FileSystemObject")
      strDriveName = fso. GetAName (strFilePath)     
      FnGetDriveName = strDriveName

End Function

Msgbox FnGetDriveName ("c:\NewFolder\file.txt")

Output : C



Also Read:

  1. FileSystemObject : CreateTextFile Method
  2. FileSystemObject : DeleteFolder Method
  3. FileSystemObject : MoveFolder Method
  4. FileSystemObject : DeleteFile Method
  5. FileSystemObject in Excel Macro
  6. VBA-Excel: Add/Insert multiple objects from a folder in an Excel Document.
  7. FileSystemObject : FileExists Method
  8. FileSystemObject : GetExtensionName Method