示例#1
0
        public void TestOpenReadReadsExistingData()
        {
            var fi = new FileInfo(longPathFilename);

            using (var fileStream = fi.OpenRead())
            {
                Assert.AreEqual('t', fileStream.ReadByte());
            }
        }
示例#2
0
 public async Task <FileSystemResult <Stream> > OpenReadAsync()
 {
     try
     {
         if (file == null)
         {
             return(new FileSystemResult <Stream>("Empty File"));
         }
         return(await Task.FromResult(new FileSystemResult <Stream>(file?.OpenRead())));
     }
     catch (Exception e)
     {
         return(await Task.FromResult(new FileSystemResult <Stream>(e.Message)));
     }
 }
示例#3
0
        public void TestOpenWriteWritesCorrectly()
        {
            var tempLongPathFilename = new StringBuilder(longPathDirectory).Append(@"\").Append("file31a.ext").ToString();
            var fi = new FileInfo(tempLongPathFilename);

            try
            {
                using (var fileStream = fi.OpenWrite())
                {
                    fileStream.WriteByte(42);
                }
                using (var fileStream = fi.OpenRead())
                {
                    Assert.AreEqual(42, fileStream.ReadByte());
                }
            }
            finally
            {
                File.Delete(tempLongPathFilename);
            }
        }
示例#4
0
 public void TestOpenWriteWritesCorrectly()
 {
     var tempLongPathFilename = new StringBuilder(longPathDirectory).Append(@"\").Append("file31a.ext").ToString();
     var fi = new FileInfo(tempLongPathFilename);
     try
     {
         using (var fileStream = fi.OpenWrite())
         {
             fileStream.WriteByte(42);
         }
         using (var fileStream = fi.OpenRead())
         {
             Assert.AreEqual(42, fileStream.ReadByte());
         }
     }
     finally
     {
         File.Delete(tempLongPathFilename);
     }
 }
示例#5
0
 public void TestOpenReadReadsExistingData()
 {
     var fi = new FileInfo(longPathFilename);
     using (var fileStream = fi.OpenRead())
     {
         Assert.AreEqual('t', fileStream.ReadByte());
     }
 }