C# exception, "The given path's format is not supported."

2.5k views Asked by At

I'm using CS-Script to compile it, and it compiled fine after I fixed all the syntax errors. I compiled it to a console application executable.

Unhandled Exception: System.NotSupportedException: The given path's format is not supported.
   at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
   at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
   at MainClass.Main(String[] argv)

I already searched through a few threads and tried a few things, and it didn't work.

    string ws = @"C:\Users\Computer 1\Desktop\Workspace2";
    string tech = @"C:\Users\Computer 1\Desktop\Tech Photos";
    string des = @"C:\Users\Computer 1\Desktop\Final";
    List<string> branches = new List<string>(Directory.GetDirectories(tech));
    branches = branches.Select(b => b.Substring(0,3)).ToList();
    string[] dirs = Directory.GetDirectories(ws);
    string[][] imgs = new string[dirs.Length][];

    for (int i = 0; i < dirs.Length; i++)
    {
        imgs[i] = Directory.GetFiles(dirs[i]);
        Array.Sort(imgs[i]);
        imgs[i].Reverse();
        string newDir = Path.Combine(des, String.Concat(branches[i], " Tech Pics"));
        Directory.CreateDirectory(newDir);
        foreach (string f in imgs[i])
        {
            List<string> words = new List<string>(f.Split(' ', '_', '-'));
            string s = branches[i] + " - ";
            foreach (string w in words)
            {
                if(Char.IsUpper(w[0]) && Char.IsLower(w[w.Length - 1]))
                    s += " " + w;
            }

            s += s.Length > 6 ? "" : "(NAMELESS) - " + i.ToString();
            s += Path.GetExtension(f);
            File.Copy(f, Path.Combine(newDir, s));
        }
    }

This program is for automatically looking through a bunch of files and renaming them in a more appropriate format. It compiles fine, but I can't get past this exception.

0

There are 0 answers