{"record":{"id":"77fde6ffe78d77d9","repo":"peass-ng/PEASS-ng","slug":"the-drive-does-not-support-ntfs-encryption-0","errorCode":null,"errorMessage":"The drive does not support NTFS encryption: [{0}]","messagePattern":"The drive does not support NTFS encryption: \\[(.+?)\\]","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File Core Methods/File.EncryptDecryptFileCore.cs","lineNumber":100,"sourceCode":"            if (isReadOnly)\n               attrs.dwFileAttributes |= FileAttributes.ReadOnly;\n\n            if (isHidden)\n               attrs.dwFileAttributes |= FileAttributes.Hidden;\n\n            SetAttributesCore(null, isFolder, path, attrs.dwFileAttributes, pathFormat);\n         }\n\n\n         if (!success)\n         {\n            switch ((uint) lastError)\n            {\n               case Win32Errors.ERROR_ACCESS_DENIED:\n\n                  if (!string.Equals(\"NTFS\", new DriveInfo(path).DriveFormat, StringComparison.OrdinalIgnoreCase))\n\n                     throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, \"The drive does not support NTFS encryption: [{0}]\", Path.GetPathRoot(path, false)));\n\n                  break;\n\n\n               case Win32Errors.ERROR_FILE_READ_ONLY:\n\n                  if (isFolder)\n                     throw new DirectoryReadOnlyException(path);\n\n                  else\n                     throw new FileReadOnlyException(path);\n\n\n               default:\n                  NativeError.ThrowException(lastError, isFolder, path);\n                  break;\n            }\n         }","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File Core Methods/File.EncryptDecryptFileCore.cs#L82-L118","documentation":"EncryptDecryptFileCore translates Win32 ERROR_ACCESS_DENIED into NotSupportedException('The drive does not support NTFS encryption') when the volume hosting the path is not NTFS. EFS (EncryptFile/DecryptFile) only works on NTFS; other filesystems (FAT32, exFAT) deny the call, and AlphaFS reports the real cause via the drive root in the message.","triggerScenarios":"Calling File.Encrypt or File.Decrypt on a file located on a FAT32/exFAT/USB/network volume; native call fails with ERROR_ACCESS_DENIED and DriveInfo(path).DriveFormat != 'NTFS'.","commonSituations":"Encrypting files on USB sticks or SD cards formatted exFAT; working from a network share (no EFS); WSL-mounted or virtual drives; moving data off an NTFS partition onto removable media.","solutions":["Move/copy the file to an NTFS volume before encrypting","Reformat the target drive as NTFS if EFS is required (data loss risk)","Check DriveInfo(path).DriveFormat == \"NTFS\" before calling Encrypt/Decrypt and skip non-NTFS volumes","Use an alternative encryption method (e.g. System.Security.Cryptography) for non-NTFS media"],"exampleFix":"// before\nFile.Encrypt(filePath);\n// after\nif (string.Equals(\"NTFS\", new DriveInfo(Path.GetPathRoot(filePath)).DriveFormat, StringComparison.OrdinalIgnoreCase))\n    File.Encrypt(filePath);\nelse\n    SkipNonNtfsEncryption(filePath);","handlingStrategy":"validation","validationCode":"bool isNtfs = string.Equals(\"NTFS\", new DriveInfo(Path.GetPathRoot(path)).DriveFormat, StringComparison.OrdinalIgnoreCase);\nif (!isNtfs) throw new NotSupportedException(\"EFS requires NTFS volume: \" + path);","typeGuard":"bool SupportsEfs(string path) { var root = Path.GetPathRoot(path); return root != null && new DriveInfo(root).IsReady && string.Equals(\"NTFS\", new DriveInfo(root).DriveFormat, StringComparison.OrdinalIgnoreCase); }","tryCatchPattern":"try { File.Encrypt(path); }\ncatch (NotSupportedException ex) { Log(ex.Message); UseAlternativeEncryption(path); }","preventionTips":["Verify drive format is NTFS before any EFS operation","Handle removable/network volumes explicitly (skip or use app-level crypto)","Test encryption features on all deployment media types (USB, network share)"],"tags":["filesystem","efs","encryption","ntfs","unsupported"],"backgroundTag":"drive-does-not-support-ntfs-encryption","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}