Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // now either rename or copy (depends on copy setting)
- if ((lrc.Copy) || (lrc.CopyTruncate))
- {
- Logging.Log(Strings.Copying + " " + fi.FullName + Strings.To + rotate_path + rotate_name, Logging.LogType.Verbose);
- if (cla.Debug == false)
- {
- try
- {
- if (bLogFileExists)
- File.Copy(fi.FullName, rotate_path + rotate_name, false);
- }
- catch (Exception e)
- {
- Logging.Log("Error copying file " + fi.FullName + " to " + rotate_path + rotate_name, Logging.LogType.Error);
- Logging.LogException(e);
- return;
- }
- if (bLogFileExists)
- {
- File.SetCreationTime(rotate_path + rotate_name, DateTime.Now);
- File.SetLastAccessTime(rotate_path + rotate_name, DateTime.Now);
- File.SetLastWriteTime(rotate_path + rotate_name, DateTime.Now);
- }
- }
- if (lrc.CopyTruncate)
- {
- Logging.Log(Strings.TruncateLogFile, Logging.LogType.Verbose);
- if (cla.Debug == false)
- {
- try
- {
- if (bLogFileExists)
- {
- FileStream fs = new FileStream(fi.FullName, FileMode.Open);
- fs.SetLength(0);
- fs.Close();
- }
- }
- catch (Exception e)
- {
- Logging.Log("Error truncating file " + fi.FullName, Logging.LogType.Error);
- Logging.LogException(e);
- return;
- }
- }
- }
- }
- else
- {
- Logging.Log(Strings.Renaming + " " + fi.FullName + Strings.To + rotate_path + rotate_name, Logging.LogType.Verbose);
- if (cla.Debug == false)
- {
- try
- {
- if (bLogFileExists)
- File.Move(fi.FullName, rotate_path + rotate_name);
- }
- catch (Exception e)
- {
- Logging.Log("Error renaming file " + fi.FullName + " to " + rotate_path + rotate_name, Logging.LogType.Error);
- Logging.LogException(e);
- return;
- }
- }
- if (lrc.Create)
- {
- Logging.Log(Strings.CreateNewEmptyLogFile, Logging.LogType.Verbose);
- if (cla.Debug == false)
- {
- try
- {
- FileStream fs = new FileStream(fi.FullName, FileMode.CreateNew);
- fs.SetLength(0);
- fs.Close();
- }
- catch (Exception e)
- {
- Logging.Log("Error creating new file " + fi.FullName, Logging.LogType.Error);
- Logging.LogException(e);
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement