Hi all,
I am not understanding the concept of PATH variable.
we are defining different path in this PATH variable. I am using one zip file and not specifying the path. See the ziputility variable in below code..
{
string arguments = @" -o " + ZipFileName; string zipUtility = @"unzip.exe";
ProcessStartInfo startInfo =
new ProcessStartInfo(zipUtility, arguments);startInfo.CreateNoWindow =
true;startInfo.UseShellExecute =
false;startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.RedirectStandardOutput =
false;startInfo.WorkingDirectory = directoryName;
Process proc = Process.Start(startInfo);
proc.WaitForExit();
}
i am not giving the path for unzip.exe file. so it should take from Environment.CurrentDirectory.. right
but in Environment.CurrentDirectory(C:\myProject\bin) also file is not there. still it's working for one application as in PATH (Environmen Variable) it's path(C:\Program Files\ZipUtility) is there.
But for another application with the same code it's giving error saying that file not found. Please Help me out in this.................................![]()

How to use PATH environment variable for an application
Burr Sutter
Thanks Appel for reply.....
I have seen that System.Diagnositic.Process does not lookup for the PATH variable if file not found in working directory.
I have created 2-3 application for the testing and all are behaving the same fashion ie. they are not taking path from the PATH variable.
So I m wondering do we need to write extra for that and as I told one appliation is taking the value from it. and that application is too huge to debug...
so I am coming to u guys for help................
My question is there in bold letters..........please reply..
supagu
Prabu.
hmmm................
Hey appel............... don't try the default exe's of windows.....................
put one exe in c:\test folder. add that path to PATH variable and
execute the same above program. then see what happens
It will give an error message..................
hdp203
- Created folder c:\test
- Copied an application to c:\test
- Added c:\test to PATH using the System Properties dialog
- Restarted Visual Studio and opened the project that contained the code above (this step is important since environment variables are inherited when the process is started)
- Changed the filename from notepad.exe to the application I copied to c:\test
- Ran the application
Are you sure that you've changed the PATH environment variable for your application when it fails You can verify this by checking the return value ofEnvironment.GetEnvironmentVariable("PATH")
using the quickwatch window for example.
Seiggy
Hey appel..............
this step is important since environment variables are inherited when the process is started)
this is the point I wanted.............I got the solution now......
Can you explain me the point in bold I mean to say Where can I get detailed information of the Process Loading.........I know what is process but I don't know much about what other things happend while process is loaded..
thanks..................
Koray Samsun
I tried the following and it worked just fine.
using System;
using System.Diagnostics;
namespace ProcessStartPathTest
{
class Program
{
static void Main(string[] args)
{
ProcessStartInfo info = new ProcessStartInfo("notepad.exe");
Process p = Process.Start(info);
Console.ReadLine();
}
}
}