Esempio n. 1
0
        public void TestCopyToWithoutOverwriteAndExistingFile()
        {
            var fi = new FileInfo(longPathFilename);
            var destLongPathFilename = new StringBuilder(longPathDirectory).Append(@"\").Append("filename (Copy).ext").ToString();

            fi.CopyTo(destLongPathFilename);

            try
            {
                Assert.IsTrue(File.Exists(destLongPathFilename));
                Assert.Throws <IOException>(() => fi.CopyTo(destLongPathFilename));
            }
            finally
            {
                File.Delete(destLongPathFilename);
            }
        }
Esempio n. 2
0
        public void TestCopyToWithOverwrite()
        {
            var fi = new FileInfo(longPathFilename);
            var destLongPathFilename = new StringBuilder(longPathDirectory).Append(@"\").Append("filename (Copy).ext").ToString();

            fi.CopyTo(destLongPathFilename);

            try
            {
                Assert.IsTrue(File.Exists(destLongPathFilename));
                fi.CopyTo(destLongPathFilename, true);
                Assert.AreEqual(File.ReadAllText(longPathFilename), File.ReadAllText(destLongPathFilename));
            }
            finally
            {
                File.Delete(destLongPathFilename);
            }
        }
Esempio n. 3
0
        public void TestCopyToWithOverwrite()
        {
            var fi = new FileInfo(longPathFilename);
            var destLongPathFilename = new StringBuilder(longPathDirectory).Append(@"\").Append("filename (Copy).ext").ToString();

            fi.CopyTo(destLongPathFilename);

            try
            {
                Assert.IsTrue(File.Exists(destLongPathFilename));
                fi.CopyTo(destLongPathFilename, true);
                Assert.AreEqual(File.ReadAllText(longPathFilename), File.ReadAllText(destLongPathFilename));
            }
            finally
            {
                File.Delete(destLongPathFilename);
            }
        }
Esempio n. 4
0
        public void TestCopyToWithoutOverwriteAndExistingFile()
        {
            var fi = new FileInfo(longPathFilename);
            var destLongPathFilename = new StringBuilder(longPathDirectory).Append(@"\").Append("filename (Copy).ext").ToString();

            fi.CopyTo(destLongPathFilename);

            try
            {
                Assert.IsTrue(File.Exists(destLongPathFilename));
                fi.CopyTo(destLongPathFilename);
            }
            finally
            {
                File.Delete(destLongPathFilename);
            }
        }