Home All Groups Group Topic Archive Search About

Determine what current drive letter is?

Author
24 Oct 2006 3:10 PM
johnb41
I need to find out what the current drive letter that is being used for
the application.  Because i want to copy/move files to a fixed path,
and don't want to hard code in "C:\" when it's not certain that the
drive exists.

Thanks for the help!
John

Author
24 Oct 2006 3:19 PM
zacks
johnb41 wrote:
> I need to find out what the current drive letter that is being used for
> the application.  Because i want to copy/move files to a fixed path,
> and don't want to hard code in "C:\" when it's not certain that the
> drive exists.
>
> Thanks for the help!
> John

By "being used by the application" do you mean the same drive the EXE
was loaded from? If so, it can be gleaned from the
Application.StartupPath property.
Author
24 Oct 2006 3:22 PM
Herfried K. Wagner [MVP]
"johnb41" <jsbuchm***@gmail.com> schrieb:
>I need to find out what the current drive letter that is being used for
> the application.  Because i want to copy/move files to a fixed path,
> and don't want to hard code in "C:\" when it's not certain that the
> drive exists.

\\\
Imports System.IO
....
MsgBox(Path.GetPathRoot(My.Application.Info.DirectoryPath))
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
24 Oct 2006 3:39 PM
johnb41
Wow, thanks guys for the quick answers.  Both answers seem to do the
trick.

It's frustrating that "my.application.bla bla" has different
properties/methods than simply "application.bla bla".  Some things are
the same, but with different names, and other things exist in one, but
not the other. :(

Thanks again!
John