Take the 2-minute tour ×

I have C# program using 7za.exe to check a zip archive using the "l" command and then extract it using the "e" command. Information about 7-Zip command line can be found at: http://www.dotnetperls.com/7-zip-examples

I can run the program from my desktop on the sever and it works great, however running it directly on the server it gives the following exception: "The system cannot find the file specified". I have verified that the file path is correct and is being passed to 7za.exe. I have attached 7za.exe as an Embedded Resource in my project and not sure why it can't find the files? Any ideas? Thanks!

Here is the code I have to verify I can open the zip archive and mostly the same to unzip except the l is an e.

Process l = new Process();
l.StartInfo.FileName = "7za.exe";
l.StartInfo.Arguments = "l " + filePath[i];
l.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
l.EnableRaisingEvents = true;
l.StartInfo.UseShellExecute = false;
l.StartInfo.RedirectStandardOutput = true;
l.Start(); // This is were it throuws the exception because it can't find the file.
// Do stuff to verify zip archive is not corrupt

Ex: filePath[i] = C:\Users\Me\Desktop\ZipFile.zip

share|improve this question
Maybe it's not able to find 7za.exe –  manojlds Sep 12 '11 at 15:26
That what I thought originally, but I believe it is stating it can't find the file meaning it found the 7za.exe –  buzzzzjay Sep 12 '11 at 15:32
@buzzzzjay: manojlds is correct. If you're getting an exception, then 7za.exe wasn't found, so starting the program failed. If 7za.exe started successfully, you'd get error messages on stdout (which you've redirected) or stderr (which you haven't), but not an exception. –  Ben Voigt Sep 12 '11 at 16:44

1 Answer 1

up vote 1 down vote accepted

The "embedded resource" can only be used with the .NET resource API, it doesn't create individual files and can't be found by normal Windows functions, such as CreateProcess (which is what Process.Start uses).

share|improve this answer
How do would I attach the exe file so that my project can run it? –  buzzzzjay Sep 12 '11 at 17:04
@buzz: Usually it's the responsibility of the setup program (installer) to copy supporting files into the program directory. If you have a setup project, it probably has an option to install additional files. If not, you can just copy it yourself. Or you can use the resource API to make a copy of the resource on disk, but you might have permissions problems when writing to that directory. –  Ben Voigt Sep 12 '11 at 18:14
You are correct. It didn't copy the exe over. I copied it over and it works great. Thanks! –  buzzzzjay Sep 12 '11 at 18:43

Your Answer


