本文整理匯總了C#中NLog.Targets.FileTarget.CreateFileStream方法的典型用法代碼示例。如果您正苦於以下問題:C# FileTarget.CreateFileStream方法的具體用法?C# FileTarget.CreateFileStream怎麽用?C# FileTarget.CreateFileStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NLog.Targets.FileTarget
的用法示例。
在下文中一共展示了FileTarget.CreateFileStream方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: MutexMultiProcessFileAppender
/// <summary>
/// Initializes a new instance of the <see cref="MutexMultiProcessFileAppender" /> class.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="target">The file target.</param>
public MutexMultiProcessFileAppender(string fileName, FileTarget target)
: base(fileName)
{
try
{
this.mutex = new Mutex(false, GetMutexName(fileName));
this.file = target.CreateFileStream(fileName, true, true);
}
catch
{
if (this.mutex != null)
{
this.mutex.Close();
this.mutex = null;
}
if (this.file != null)
{
this.file.Close();
this.file = null;
}
throw;
}
}
示例2: CountingSingleProcessFileAppender
/// <summary>
/// Initializes a new instance of the <see cref="CountingSingleProcessFileAppender" /> class.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="target">The file target.</param>
public CountingSingleProcessFileAppender(string fileName, FileTarget target)
: base(fileName)
{
var fi = new FileInfo(fileName);
if (fi.Exists)
{
this.FileTouched(fi.LastWriteTime);
this.currentFileLength = fi.Length;
}
else
{
this.FileTouched();
this.currentFileLength = 0;
}
this.file = target.CreateFileStream(fileName, false, false);
}