KirChhOff
KirChhOff

Reputation: 21

How do i get drive letter for a running form

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

Upvotes: 0

Views: 1781

Answers (3)

lardymonkey
lardymonkey

Reputation: 778

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

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

Upvotes: 0

Amarildo Lena
Amarildo Lena

Reputation: 64

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)

Upvotes: 0

KirChhOff
KirChhOff

Reputation: 21

Dim disk_letter As String
disk_letter = Left(CurDir$(), 1)

That was all.

Upvotes: 1

Related Questions