Reputation: 32292
Is there a library method somewhere for figuring out whether a file has been encrypted with EFS? I see the Encrypt()
and Decrypt()
methods on FileInfo, but am looking for a way to query a file's state.
Upvotes: 3
Views: 4147
Reputation: 3059
To expand on bdolan & matt's comment:
<snip>
using System.IO;
<snip>
FileInfo fi = new FileInfo(uri); //uri is the full path and file name
if (fi.Attributes.HasFlag(FileAttributes.Encrypted))
{
//FILE IS ENCRYPTED
}
else
{
//FILE IS SAFE
}
Upvotes: 6
Reputation: 231333
Use GetFileAttributes()
, and check for FILE_ATTRIBUTE_ENCRYPTED
.
Upvotes: 5