public static void SeekFileStreamHelper(FileStream fs, long offset, SeekOrigin origin) { try { fs.Seek(offset, origin); } catch (IOException e) { LogFileException ex = new LogFileException(SR.GetString("MsgIOExceptionSeek") + fs.Name + SR.GetString("MsgFilePathEnd"), fs.Name, e); ExceptionManager.LogAppError(ex); throw ex; } catch (NotSupportedException e2) { LogFileException ex2 = new LogFileException(SR.GetString("MsgFailToSeekFile") + fs.Name + SR.GetString("MsgFilePathEnd"), fs.Name, e2); ExceptionManager.LogAppError(ex2); throw ex2; } catch (ArgumentException e3) { LogFileException ex3 = new LogFileException(SR.GetString("MsgFailToSeekFile") + fs.Name + SR.GetString("MsgFilePathEnd"), fs.Name, e3); ExceptionManager.LogAppError(ex3); throw ex3; } catch (ObjectDisposedException e4) { LogFileException ex4 = new LogFileException(SR.GetString("MsgFailToSeekFile") + fs.Name + SR.GetString("MsgFilePathEnd") + SR.GetString("MsgStreamClosed"), fs.Name, e4); ExceptionManager.LogAppError(ex4); throw ex4; } }
public static FileStream CreateFileStreamHelper(string filePath, FileMode mode, FileAccess access, FileShare share) { try { return(new FileStream(filePath, mode, access, share)); } catch (ArgumentException e) { LogFileException ex = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgFilePathNotSupport"), filePath, e); ExceptionManager.LogAppError(ex); throw ex; } catch (FileNotFoundException e2) { LogFileException ex2 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgFileNotFound"), filePath, e2); ExceptionManager.LogAppError(ex2); throw ex2; } catch (SecurityException e3) { LogFileException ex3 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgAccessDenied"), filePath, e3); ExceptionManager.LogAppError(ex3); throw ex3; } catch (DirectoryNotFoundException e4) { LogFileException ex4 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgDirectoryNotFound"), filePath, e4); ExceptionManager.LogAppError(ex4); throw ex4; } catch (UnauthorizedAccessException e5) { LogFileException ex5 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgAccessDenied"), filePath, e5); ExceptionManager.LogAppError(ex5); throw ex5; } catch (PathTooLongException e6) { LogFileException ex6 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgFilePathTooLong"), filePath, e6); ExceptionManager.LogAppError(ex6); throw ex6; } catch (NotSupportedException e7) { LogFileException ex7 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgFilePathNotSupport"), filePath, e7); ExceptionManager.LogAppError(ex7); throw ex7; } catch (IOException e8) { LogFileException ex8 = new LogFileException(SR.GetString("MsgIOException") + filePath + SR.GetString("MsgFilePathEnd"), filePath, e8); ExceptionManager.LogAppError(ex8); throw ex8; } }
public static BinaryReader CreateBinaryReaderHelper(FileStream fs) { try { return(new BinaryReader(fs)); } catch (ArgumentException e) { LogFileException ex = new LogFileException(SR.GetString("MsgCannotOpenFile") + fs.Name + SR.GetString("MsgFilePathEnd"), fs.Name, e); ExceptionManager.LogAppError(ex); throw ex; } }
public static StreamReader CreateStreamReaderHelper(FileStream fs) { try { return(new StreamReader(fs)); } catch (ArgumentException e) { LogFileException ex = new LogFileException(SR.GetString("MsgFileStreamNotReadable"), fs.Name, e); ExceptionManager.LogAppError(ex); throw ex; } }
public static byte[] ReadBytesHelper(BinaryReader binaryReader, int count) { try { return(binaryReader.ReadBytes(count)); } catch (IOException e) { LogFileException ex = new LogFileException(SR.GetString("MsgBinaryReaderExp") + SR.GetString("MsgReturnBack") + SR.GetString("MsgIOExp"), string.Empty, e); ExceptionManager.LogAppError(ex); throw ex; } catch (ObjectDisposedException e2) { LogFileException ex2 = new LogFileException(SR.GetString("MsgBinaryReaderExp") + SR.GetString("MsgReturnBack") + SR.GetString("MsgStreamClosed"), string.Empty, e2); ExceptionManager.LogAppError(ex2); throw ex2; } }