Is there a default path for vb?

So they’re just curious, in batch mode, they have a default way to specify the source drive or folder path as follows: %drive%for your drive C:\or any other drive of yours, or as %windir%for the Windows directory. I need this to extract files to a Windows folder, and some people may have instead C:\or Windows.001instead D:\. Is there a way to do this in vb 2008-2012?

+3
source share
2 answers

You are looking for System.Environment.GetFolderPath using Environment.SpecialFolder . Or you can use System.Environment.GetEnvironmentVariable if you know the name of the environment variable.

From the last link:

Environment.CurrentDirectory = Environment.GetEnvironmentVariable("windir")
+4
source

To go to the folder in the root directory: when calling the file path instead of the query: "C: \ Root folder you want" Use: "\ Root Folder You Want".

But it depends on the system, because people have different folders (for example, Program Files vs. Program Files (x86)), in which case you can use the System.Environment function to find the version of the OS that they run, etc. d.

The documentation can be found here: Environment Methods

Visual Studio EDIT, INSERT SNIPPET, .

+2

All Articles