当前位置: 首页>>代码示例>>C#>>正文


C# Pri.LongPath.FileInfo.Open方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:jerriclynsjohn,项目名称:LongPath,代码行数:26,代码来源:FileTests.cs

示例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);
     }
 }
开发者ID:KsWare,项目名称:LongPath,代码行数:16,代码来源:FileInfoTests.cs

示例3: TestOpenOpen

 public void TestOpenOpen()
 {
     var fi = new FileInfo(longPathFilename);
     using (var fileStream = fi.Open(FileMode.Open))
     {
         Assert.IsNotNull(fileStream);
     }
 }
开发者ID:KsWare,项目名称:LongPath,代码行数:8,代码来源:FileInfoTests.cs

示例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);
            }
        }
开发者ID:KsWare,项目名称:LongPath,代码行数:23,代码来源:FileInfoTests.cs

示例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);
            }
        }
开发者ID:KsWare,项目名称:LongPath,代码行数:22,代码来源:FileInfoTests.cs

示例6: TestOpenCreateNew

		public void TestOpenCreateNew()
		{
			var fi = new FileInfo(filePath);
			using (var fileStream = fi.Open(FileMode.CreateNew))
			{
				Assert.IsNotNull(fileStream);
			}
		}
开发者ID:HMartyrossian,项目名称:LongPath,代码行数:8,代码来源:UncFileInfoTests.cs


注:本文中的Pri.LongPath.FileInfo.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。