Matt
Matt

Reputation: 32292

How to determine whether a file is encrypted with EFS?

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

Answers (2)

Atron Seige
Atron Seige

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

bdonlan
bdonlan

Reputation: 231333

Use GetFileAttributes(), and check for FILE_ATTRIBUTE_ENCRYPTED.

Upvotes: 5

Related Questions