{"record":{"id":"98618e157a785921","repo":"peass-ng/PEASS-ng","slug":"resources-unsupported-path-format","errorCode":null,"errorMessage":"Resources.Unsupported_Path_Format","messagePattern":"Resources\\.Unsupported_Path_Format","errorType":"validation","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CreateDirectoryCore.cs","lineNumber":142,"sourceCode":"                     // MSDN: .NET 3.5+: If the directory already exists, this method does nothing.\n                     // MSDN: .NET 3.5+: IOException: The directory specified by path is a file.\n                     case Win32Errors.ERROR_ALREADY_EXISTS:\n                        if (File.ExistsCore(transaction, false, longPath, PathFormat.LongFullPath))\n                           NativeError.ThrowException(lastError, longPath);\n\n                        if (File.ExistsCore(transaction, false, folderLp, PathFormat.LongFullPath))\n                           NativeError.ThrowException(Win32Errors.ERROR_PATH_NOT_FOUND, null, folderLp);\n                        break;\n\n\n                     case Win32Errors.ERROR_BAD_NET_NAME:\n                        NativeError.ThrowException(Win32Errors.ERROR_BAD_NET_NAME, longPath);\n                        break;\n\n\n                     case Win32Errors.ERROR_DIRECTORY:\n                        // MSDN: .NET 3.5+: NotSupportedException: path contains a colon character (:) that is not part of a drive label (\"C:\\\").\n                        throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, Resources.Unsupported_Path_Format, longPath));\n\n\n                     case Win32Errors.ERROR_ACCESS_DENIED:\n                        // Report the parent folder, the inaccessible folder.\n                        var parent = GetParent(folderLp);\n\n                        NativeError.ThrowException(lastError, null != parent ? parent.FullName : folderLp);\n                        break;\n\n\n                     default:\n                        NativeError.ThrowException(lastError, true, folderLp);\n                        break;\n                  }\n               }\n\n               else if (compress)\n                  Device.ToggleCompressionCore(transaction, true, folderLp, true, PathFormat.LongFullPath);","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CreateDirectoryCore.cs#L124-L160","documentation":"Inside CreateDirectoryCore, when the native Win32 call fails with ERROR_DIRECTORY, AlphaFS throws NotSupportedException reporting that the path format is unsupported. Per MSDN this corresponds to path containing a colon character (':' ) that is not part of a drive label (e.g. \"C:\\\"). AlphaFS maps that native error to Resources.Unsupported_Path_Format with the offending long path.","triggerScenarios":"Calling Directory.CreateDirectory (or CreateDirectoryTransacted / CreateJunction which call the core) with a path containing an illegal colon, e.g. \"C:\\dir\\name:stream\" (NTFS alternate data stream syntax) or \"http://server/path\".","commonSituations":"Passing URL/URI strings directly as directory paths; accidentally building paths with time strings like \"12:30\" in the folder name; alternate-data-stream style names; path assembled from user input containing ':' on a non-drive position.","solutions":["Remove or replace the illegal colon in the path; sanitize user-supplied folder names (strip ':' or replace with '-').","If a URI was passed, convert to a local filesystem path first (e.g. uri.LocalPath) or use appropriate network APIs instead.","Validate the path with Path.GetInvalidPathChars / a regex allowing ':' only at index 1 (drive label) before calling.","Catch NotSupportedException to surface a friendly message identifying the bad path (the exception message embeds longPath)."],"exampleFix":"// before\nDirectory.CreateDirectory($\"C:\\\\logs\\\\{DateTime.Now.ToString(\"HH:mm\")}\");\n// after\nDirectory.CreateDirectory($\"C:\\\\logs\\\\{DateTime.Now.ToString(\"HH-mm\")}\");","handlingStrategy":"validation","validationCode":"static void EnsureNoIllegalColon(string path)\n{\n    // ':' only allowed as drive separator at index 1\n    for (int i = 0; i < path.Length; i++)\n        if (path[i] == ':' && i != 1)\n            throw new ArgumentException($\"Illegal ':' at position {i} in '{path}'\");\n}\nEnsureNoIllegalColon(path);\nDirectory.CreateDirectory(path);","typeGuard":"static bool IsWellFormedLocalPath(string p) =>\n    !string.IsNullOrEmpty(p) && p.IndexOf(':') is -1 or 1;","tryCatchPattern":"try\n{\n    Directory.CreateDirectory(path);\n}\ncatch (NotSupportedException ex)\n{\n    // message embeds the offending longPath\n    throw new InvalidOperationException($\"Path contains an unsupported character (stray ':'): {path}\", ex);\n}","preventionTips":["Strip or escape ':' from user/file-name-derived folder names.","Convert URIs with uri.LocalPath before treating them as filesystem paths.","Avoid embedding time/formatted strings containing ':' in paths; use '-' instead.","Run Path.GetFullPath early to surface malformed paths with a clearer error."],"tags":["notsupported","path-format","illegal-characters","alphafs","dotnet"],"backgroundTag":"invalid-path-characters","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}