Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 773
Matt Avatar asked Jan 01 '26 18:01

Matt


2 Answers

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
}
like image 162
Atron Seige Avatar answered Jan 03 '26 07:01

Atron Seige


Use GetFileAttributes(), and check for FILE_ATTRIBUTE_ENCRYPTED.

like image 33
bdonlan Avatar answered Jan 03 '26 07:01

bdonlan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!