Hi everybody :-)
I wrote a console application which produces backup from my database and then compresses it to an rar file. it works fine except when it is scheduled in windows 2008. after windows runs my application,it says that it runs completely. but it doesn't compress my file . it only produces backup for me. by the way the windows is windows **server 2008** here is my code to convert backup file to rar file:
private static void ConvertBackupToRar(string backupFileName)
{
Console.WriteLine("Convert Backup to rar file");
try
{
string compressStr = ConfigurationManager.AppSettings["BackupFolderAddress"].Trim() + @"Compress.bat";
FileInfo fbat = new FileInfo(compressStr);
StreamWriter fs = fbat.CreateText();
fs.WriteLine("Winrar a " + backupFileName.Replace(".bak", ".rar") + " " + backupFileName);
fs.Flush();
fs.Close();
System.Threading.Thread.Sleep(5000);
using (System.Diagnostics.Process process1 = new System.Diagnostics.Process())
{
process1.StartInfo.FileName = compressStr;
process1.Start();
}
}
catch (Exception exp)
{
throw exp;
}
}