Example #1
0
        private static bool IsValidFilePath(BackupMetadata meta)
        {
            if (BackupFileTools.IsUrl(meta.PhysicalDeviceName))
            {
                return(true);
            }

            // A quick check before leaning on exceptions
            if (Path.GetInvalidPathChars().Any(meta.PhysicalDeviceName.Contains))
            {
                return(false);
            }

            try {
                // This will throw an argument exception if the path is invalid
                Path.GetFullPath(meta.PhysicalDeviceName);
                // A relative path won't help us much if the destination is another server. It needs to be rooted.
                return(Path.IsPathRooted(meta.PhysicalDeviceName));
            }
            catch (Exception) {
                return(false);
            }
        }
Example #2
0
 public void NonUrlFilesAreNotUrl(string file)
 {
     Assert.False(BackupFileTools.IsUrl(file));
 }
Example #3
0
 public void UrlFilesAreUrl(string file)
 {
     Assert.True(BackupFileTools.IsUrl(file));
 }