How do i get drive letter for a running form

1.6k Views Asked by At

I need to get the letter of the drive my form is running from. The reason why i need this, is because i'll be copying a text file (from the removable drive in which the form will be) to the computer. Is it even possible? If yes could someone help me with the code?

NOTE I'm using Visual Basic 6

3

There are 3 best solutions below

0
On BEST ANSWER
Dim disk_letter As String
disk_letter = Left(CurDir$(), 1)

That was all.

0
On

This should return you the drive letter that you are running the exe from.

Left$(App.Path, InStr(App.Path, ":"))
1
On

I think this is the best approach considering the drive letter can have more than one letter.

Dim driveLetter As String
driveLetter = Left$(App.path, InStr(App.path, ":") - 1)