As per this CodeProject, I have encrypted and decrypted file.
At the end of the code, I am setting file attribute as Encrypted
.
fsIn.Close();
cs.Close();
fsCrypt.Close();
// Mark the file as Encrypted
File.SetAttributes(outputFile, File.GetAttributes(outputFile) | FileAttributes.Encrypted);
and when I am done with decrypt.
// Mark the file Decrypted
File.SetAttributes(outputFile, File.GetAttributes(outputFile) & ~FileAttributes.Encrypted);
And here is how I am checking:
public static bool IsFileEncrypted(string filePath)
{
FileAttributes attributes = File.GetAttributes(filePath);
return (attributes & FileAttributes.Encrypted) == FileAttributes.Encrypted;
}
The problem is, variable attributes
shows only Archive
attribute.
How I can check whether File is encrypted or not? Is there any other solution?