Exemple #1
0
 public static FileEntry GetChild(this DirectoryEntry self, string fileName, bool sanitize = true)
 {
     fileName.ThrowErrorIfNullOrEmpty("fileName");
     if (sanitize)
     {
         fileName = Sanitize.SanitizeToFileName(fileName);
     }
     AssertV2.AreEqual(fileName, Sanitize.SanitizeToFileName(fileName));
     return(ResolveFilePath(self, fileName));
 }
Exemple #2
0
 public static DirectoryEntry GetChildDir(this DirectoryEntry self, string subDirName, bool sanitize = true)
 {
     subDirName.ThrowErrorIfNullOrEmpty("subDirName");
     if (sanitize)
     {
         subDirName = Sanitize.SanitizeToDirName(subDirName);
     }
     AssertV2.AreEqual(subDirName, Sanitize.SanitizeToDirName(subDirName));
     return(ResolveDirectoryPath(self, subDirName));
 }
Exemple #3
0
        public static DirectoryInfo GetChildDir(this DirectoryInfo self, string subDirName, bool assertThatChildMustExist = false, bool sanitize = true)
        {
            subDirName.ThrowErrorIfNullOrEmpty("subDirName");
            if (sanitize)
            {
                subDirName = Sanitize.SanitizeToDirName(subDirName);
            }
            AssertV2.AreEqual(subDirName, Sanitize.SanitizeToDirName(subDirName));
            var c = new DirectoryInfo(self.FullPath() + subDirName);

            if (assertThatChildMustExist)
            {
                AssertV2.IsTrue(c.IsNotNullAndExists(), "childFolder '" + subDirName + "' doesnt exist! Path=" + c.FullPath());
            }
            return(c);
        }
Exemple #4
0
        public static FileInfo GetChild(this DirectoryInfo self, string fileName, bool assertThatChildMustExist = false, bool sanitize = true)
        {
            fileName.ThrowErrorIfNullOrEmpty("fileName");
            if (sanitize)
            {
                fileName = Sanitize.SanitizeToFileName(fileName);
            }
            AssertV2.AreEqual(fileName, Sanitize.SanitizeToFileName(fileName));
            var c = new FileInfo(self.FullPath() + fileName);

            if (assertThatChildMustExist)
            {
                AssertV2.IsTrue(c.IsNotNullAndExists(), "childFile '" + fileName + "' doesnt exist! Path=" + c.FullPath());
            }
            return(c);
        }