/// </summary>\r
public class Encode : IEncode\r
{\r
-\r
#region Private Variables\r
\r
/// <summary>\r
{\r
if (this.IsEncoding == false)\r
{\r
- ReadFile(); // Read the last log file back in if it exists\r
+ try\r
+ {\r
+ ReadFile(); // Read the last log file back in if it exists\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ return exc.ToString();\r
+ }\r
}\r
\r
return string.IsNullOrEmpty(this.logBuffer.ToString()) ? "No log data available..." : this.logBuffer.ToString();\r
\r
try\r
{\r
- // Make sure the application readable log file does not already exist. FileCopy fill fail if it does.\r
- if (File.Exists(logFile2))\r
- File.Delete(logFile2);\r
-\r
// Copy the log file.\r
if (File.Exists(logFile))\r
File.Copy(logFile, logFile2, true);\r
\r
// Start the Reader\r
// Only use text which continues on from the last read line\r
- StreamReader sr = new StreamReader(logFile2);\r
- string line;\r
- int i = 1;\r
- while ((line = sr.ReadLine()) != null)\r
+ using (StreamReader sr = new StreamReader(logFile2))\r
{\r
- if (i > logFilePosition)\r
+ string line;\r
+ int i = 1;\r
+ while ((line = sr.ReadLine()) != null)\r
{\r
- logBuffer.AppendLine(line);\r
- logFilePosition++;\r
+ if (i > logFilePosition)\r
+ {\r
+ logBuffer.AppendLine(line);\r
+ logFilePosition++;\r
+ }\r
+ i++;\r
}\r
- i++;\r
+ sr.Close();\r
}\r
- sr.Close();\r
- sr.Dispose();\r
}\r
catch (Exception exc)\r
{\r
- errorService.ShowError("Unable to read log file", exc.ToString());\r
+ throw new Exception("Unable to read log file" + Environment.NewLine + exc);\r
}\r
}\r
}\r
{\r
if (fileWriter != null)\r
fileWriter.Close();\r
+\r
errorService.ShowError("Error", exc.ToString());\r
}\r
}\r
}\r
catch (Exception exc)\r
{\r
- errorService.ShowError("Unable to write log data...", exc.ToString());\r
+ // errorService.ShowError("Unable to write log data...", exc.ToString());\r
}\r
}\r
}\r
}\r
catch (Exception exc)\r
{\r
- errorService.ShowError("An Unknown Error has occured", exc.ToString());\r
+ EncodeOnEncodeProgress(null, 0, 0, 0, 0, 0, "Unknown, status not available..");\r
}\r
}\r
\r