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); } }
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); } }
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); } }