How to determine whether a file is encrypted with EFS?

3.9k views Asked by At

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.

2

There are 2 answers

2
bdonlan On BEST ANSWER
0
Atron Seige On

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
}