本文整理汇总了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);
}