示例#1
0
        public void CreateLongPathStream()
        {
            using (var cleaner = new TestFileCleaner(useDotNet: false))
            {
                string longPath = PathGenerator.CreatePathOfLength(cleaner.TempFolder, 300);
                cleaner.FileService.CreateDirectory(longPath);

                string filePath = Paths.Combine(longPath, Path.GetRandomFileName());
                using (Stream fileStream = cleaner.FileService.CreateFileStream(filePath, FileMode.CreateNew))
                {
                    fileStream.Should().NotBeNull();
                }
            }
        }
示例#2
0
        public void WriteAndReadLongPathStream()
        {
            using (var cleaner = new TestFileCleaner(useDotNet: false))
            {
                string longPath = PathGenerator.CreatePathOfLength(cleaner.TempFolder, 300);

                cleaner.FileService.CreateDirectory(longPath);
                string filePath = Paths.Combine(longPath, Path.GetRandomFileName());
                using (Stream fileStream = cleaner.FileService.CreateFileStream(filePath, FileMode.CreateNew, FileAccess.ReadWrite))
                {
                    fileStream.Should().NotBeNull();
                    StreamWriter writer = new StreamWriter(fileStream);
                    writer.WriteLine("This is a test string.");
                    writer.Flush();
                    fileStream.Position = 0;
                    StreamReader reader   = new StreamReader(fileStream);
                    string       readLine = reader.ReadLine();
                    readLine.Should().Be("This is a test string.");
                }
            }
        }