コード例 #1
0
        public void FtpFileReadTest()
        {
            ReadOnlyFile ftpFile = new ReadOnlyFile("ftp://speedtest.tele2.net/1KB.zip");

            using (ReadOnlyStream s = ftpFile.Open())
            {
                byte[] data = s.ReadAllBytes();
                Assert.AreEqual(data.Length, 0x400);
                Assert.IsFalse(s.CanWrite);

                var temp = Utility.GetTempFilePath();
                ftpFile.Copy(temp);
                Assert.IsTrue(data.IsEqual(File.ReadAllBytes(temp)));
                File.Delete(temp);
            }
        }
コード例 #2
0
        public void LocalFileReadTest()
        {
            ReadOnlyFile localFile = new ReadOnlyFile(@"C:\Windows\notepad.exe");

            using (ReadOnlyStream s = localFile.Open())
            {
                byte[] data = s.ReadAllBytes();
                Assert.IsTrue(s.Length > 0);
                Assert.AreEqual(data.Length, s.Length);
                Assert.IsFalse(s.CanWrite);

                var temp = Utility.GetTempFilePath();
                localFile.Copy(temp);
                Assert.IsTrue(data.IsEqual(File.ReadAllBytes(temp)));
                File.Delete(temp);
            }
        }