本文整理汇总了C#中Pri.LongPath.FileInfo.CreateText方法的典型用法代码示例。如果您正苦于以下问题:C# Pri.LongPath.FileInfo.CreateText方法的具体用法?C# Pri.LongPath.FileInfo.CreateText怎么用?C# Pri.LongPath.FileInfo.CreateText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pri.LongPath.FileInfo
的用法示例。
在下文中一共展示了Pri.LongPath.FileInfo.CreateText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestOpenAppend
public void TestOpenAppend()
{
var tempLongPathFilename = new StringBuilder(longPathDirectory).Append(@"\").Append("file26.ext").ToString();
var fi = new FileInfo(tempLongPathFilename);
using (var streamWriter = fi.CreateText())
{
streamWriter.WriteLine("file26");
}
try
{
using (var fileStream = fi.Open(System.IO.FileMode.Append))
{
Assert.IsNotNull(fileStream);
using (var streamWriter = new System.IO.StreamWriter(fileStream))
{
streamWriter.WriteLine("eof");
}
}
Assert.AreEqual("file26" + Environment.NewLine + "eof" + Environment.NewLine, File.ReadAllText(fi.FullName));
}
finally
{
File.Delete(tempLongPathFilename);
}
}
示例2: TestCreateText
public void TestCreateText()
{
var tempLongPathFilename = new StringBuilder(longPathDirectory).Append(@"\").Append("file20.ext").ToString();
var fi = new FileInfo(tempLongPathFilename);
Assert.IsFalse(fi.Exists);
using (fi.CreateText())
{
}
try
{
Assert.IsTrue(File.Exists(fi.FullName)); // don't use FileInfo.Exists, it caches existance
}
finally
{
fi.Delete();
}
}