示例#1
0
        public void FilterdCopyTest()
        {
            string src = Path.Combine(_TestPath, "CopySrc");

            if (Directory.Exists(src))
            {
                Directory.Delete(src, true);
            }
            Directory.CreateDirectory(src);
            const string subFolder     = "CopySubFolder";
            string       subFolderPath = Path.Combine(src, subFolder);

            Directory.CreateDirectory(subFolderPath);
            const string name    = "T1.xhtml";
            string       srcName = Path.Combine(src, name);

            File.Copy(Path.Combine(_TestPath, name), srcName);
            File.SetAttributes(srcName, File.GetAttributes(srcName) & ~FileAttributes.ReadOnly);
            string subFilePath = Path.Combine(subFolderPath, name);

            File.Copy(Path.Combine(_TestPath, name), subFilePath);
            File.SetAttributes(subFilePath, File.GetAttributes(subFilePath) & ~FileAttributes.ReadOnly);
            string dst = Path.Combine(_TestPath, "CopyDst");

            if (Directory.Exists(dst))
            {
                Directory.Delete(dst);
            }
            MyFolders.Copy(src, dst, subFolder);
            Assert.AreEqual(false, Directory.Exists(Path.Combine(dst, subFolder)), "Folder exists when it should have been filtered");
            Directory.Delete(src, true);
            Directory.Delete(dst, true);
        }
示例#2
0
        public void CopyTest()
        {
            string src = Path.Combine(_TestPath, "CopySrc");

            Directory.CreateDirectory(src);
            const string name    = "T1.xhtml";
            string       srcName = Path.Combine(src, name);

            File.Copy(Path.Combine(_TestPath, name), srcName);
            File.SetAttributes(srcName, File.GetAttributes(srcName) & ~FileAttributes.ReadOnly);
            string dst = Path.Combine(_TestPath, "CopyDst");

            MyFolders.Copy(src, dst, "");
            Assert.AreEqual(true, File.Exists(Path.Combine(dst, name)));
            Directory.Delete(src, true);
            Directory.Delete(dst, true);
        }