/// <summary> /// 初始化文件流 /// </summary> /// <param name="fStream"></param> /// <returns></returns> private bool InitFileStream(ref FileStream fStream) { string path = LogPath + OperateFile.DEFULT_NAME; CreateLogPath(); int bufferSize = 1024; try { if (File.Exists(path)) { fStream = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.ReadWrite, bufferSize, FileOptions.Asynchronous); } else { fStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite, bufferSize, FileOptions.Asynchronous); } } catch (Exception ex) { OperateFile.ShowException(ex, new StackTrace(true)); return(false); } return(fStream.CanWrite); }
/// <summary> /// 创建日志路径 /// </summary> private void CreateLogPath() { this.LogPath = OperateFile.CreateLogDirectory(this.LogPath); }