public void TestOpenReadReadsExistingData() { var fi = new FileInfo(longPathFilename); using (var fileStream = fi.OpenRead()) { Assert.AreEqual('t', fileStream.ReadByte()); } }
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))); } }
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); } }