All,
i'm using 7zip to archive data that my application produces, the
following code fails to work. The problem is, the code seems to
redirect where its looking for the 7z.exe to where-ever the
SaveFileDialog is pointed at to save the document.
if (this.saveFileDialog1.ShowDialog(this) != DialogResult.Cancel)
{
string strFileLocation = "C:\\temp\\";
string strFileName;
string strFileToZip = "c:\\temp\\reports";
string strSB;
strFileName = this.saveFileDialog1.FileName;
StringBuilder SB = new StringBuilder();
SB.Append ("/c ");
SB.Append ("7za ");
SB.Append ("a ");
SB.Append (strFileLocation);
SB.Append (strFileName);
SB.Append (" ");
SB.Append (strFileToZip);
strSB = SB.ToString();
ProcessStartInfo psiOpt = new ProcessStartInfo(@"cmd.exe", strSB);
psiOpt.WindowStyle = ProcessWindowStyle.Normal;
psiOpt.RedirectStandardOutput = true;
psiOpt.UseShellExecute = false;
psiOpt.CreateNoWindow = true;
// Create the actual process object
Process procCommand = Process.Start(psiOpt);
// Receives the output of the Command Prompt
StreamReader srIncoming = procCommand.StandardOutput;
// Show the result
MessageBox.Show(srIncoming.ReadToEnd());
// Close the process
procCommand.WaitForExit();
}
if i dont use the savefiledialog and use:
strFileName = C:\temp\archive%DATE:/=_%.zip, this works perfect to the
preset location in the string text.
Any ideas how i can retain the .exe location wihtout it changing by
using savefiledialog?
Cheers