|
|
I was writing a program where I had to resolve its fully qualified path using Environment Variables. Here’s how it is done using the ‘PATH’ Environment variable
static void Main(string[] args)
{
// List Environment Variables
foreach (DictionaryEntry de in Environment.GetEnvironmentVariables())
Console.WriteLine("{0}={1}", de.Key, de.Value);
Console.WriteLine("--------------");
Console.WriteLine("Fully Qualified Path");
string ext = "notepad.exe";
string fullPath = Environment.GetEnvironmentVariable("PATH")
.Split(';')
.FirstOrDefault(p => File.Exists(Path.Combine(p, ext)));
Console.WriteLine(fullPath);
Console.ReadLine();
}
OUTPUT (partial)

'Like' us on our FaceBook page if you find this blog useful. Thanks!
Did you like this post?
|
|
|
||
|
|
|
|
Save on Delicious |
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |




comments
1 Response to "Fully Qualified Path in .NET"Will try to follow each step - sounds interesting though
Post a Comment