本文整理汇总了C#中Pri.LongPath.FileInfo.Open方法的典型用法代码示例。如果您正苦于以下问题:C# Pri.LongPath.FileInfo.Open方法的具体用法?C# Pri.LongPath.FileInfo.Open怎么用?C# Pri.LongPath.FileInfo.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pri.LongPath.FileInfo
的用法示例。
在下文中一共展示了Pri.LongPath.FileInfo.Open方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: TestOpenReadWithWrite
public void TestOpenReadWithWrite()
{
var tempLongPathFilename = new StringBuilder(longPathDirectory).Append(@"\").Append("file31.ext").ToString();
var fi = new FileInfo(tempLongPathFilename);
try
{
using (var fileStream = fi.Open(FileMode.Append, FileAccess.Read))
{
fileStream.WriteByte(43);
}
}
finally
{
File.Delete(tempLongPathFilename);
}
}
示例3: TestOpenOpen
public void TestOpenOpen()
{
var fi = new FileInfo(longPathFilename);
using (var fileStream = fi.Open(FileMode.Open))
{
Assert.IsNotNull(fileStream);
}
}
示例4: TestOpenHidden
public void TestOpenHidden()
{
var tempLongPathFilename = new StringBuilder(longPathDirectory).Append(@"\").Append("file25.ext").ToString();
var fi = new FileInfo(tempLongPathFilename);
using (fi.Create())
{
}
try
{
File.SetAttributes(fi.FullName, File.GetAttributes(fi.FullName) | FileAttributes.Hidden);
using (var fileStream = fi.Open(FileMode.Create))
{
Assert.IsNotNull(fileStream);
}
}
finally
{
File.Delete(tempLongPathFilename);
}
}
示例5: TestOpenCreatesEmpty
public void TestOpenCreatesEmpty()
{
var tempLongPathFilename = Path.Combine(longPathDirectory, Path.GetRandomFileName());
try
{
using (var writer = File.CreateText(tempLongPathFilename))
{
writer.WriteLine("test");
}
var fi = new FileInfo(tempLongPathFilename);
using (var fileStream = fi.Open(FileMode.Append, FileAccess.Read, FileShare.Read))
{
Assert.AreEqual(-1, fileStream.ReadByte());
}
}
finally
{
File.Delete(tempLongPathFilename);
}
}
示例6: TestOpenCreateNew
public void TestOpenCreateNew()
{
var fi = new FileInfo(filePath);
using (var fileStream = fi.Open(FileMode.CreateNew))
{
Assert.IsNotNull(fileStream);
}
}