/// <summary> /// Writes the header information to a file. /// </summary> /// <param name="appender">File appender associated with the file.</param> private void WriteHeader(BaseFileAppender appender) { //performance: cheap check before checking file info if (Header == null) return; //todo replace with hasWritten? var length = appender.GetFileLength(); // Write header only on empty files or if file info cannot be obtained. if (length == null || length == 0) { byte[] headerBytes = this.GetHeaderBytes(); if (headerBytes != null) { appender.Write(headerBytes); } } }
/// <summary> /// Writes the header information to a file. /// </summary> /// <param name="appender">File appender associated with the file.</param> private void WriteHeader(BaseFileAppender appender) { FileCharacteristics fileCharacteristics = appender.GetFileCharacteristics(); // Write header only on empty files or if file info cannot be obtained. if ((fileCharacteristics == null) || (fileCharacteristics.FileLength == 0)) { byte[] headerBytes = this.GetHeaderBytes(); if (headerBytes != null) { appender.Write(headerBytes); } } }
/// <summary> /// Writes the header information to a file. /// </summary> /// <param name="appender">File appender associated with the file.</param> private void WriteHeader(BaseFileAppender appender) { long fileLength; DateTime lastWriteTime; // Write header only on empty files or if file info cannot be obtained. if (!appender.GetFileInfo(out lastWriteTime, out fileLength) || fileLength == 0) { byte[] headerBytes = this.GetHeaderBytes(); if (headerBytes != null) { appender.Write(headerBytes); } } }