Reputation: 49
I tried codeproject help as well as MSDN but no success. Here is a copy of my test code returning an exception:
private void button2_Click(object sender, EventArgs e)
{
File.Decrypt("Text.pvf");
string[] DataFile = File.ReadAllLines("Text.pvf");
if (DataFile[5] == "6")
MessageBox.Show("Encrypt/Decrypt successful");
//Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
string[] DataFile = new string[6];
DataFile[0] = "1";
DataFile[1] = "2";
DataFile[2] = "3";
DataFile[3] = "4";
DataFile[4] = "5";
DataFile[5] = "6";
File.WriteAllLines("Text.pvf", DataFile);
File.Encrypt("Text.pvf");
}
At the line: "File.Encrypt("Text.pvf");
", I get an IOException that says: 'The request is not supported.'. Now the button1
method is called first. I do not know why this error comes up.
My pc: Windows7 64bit, .net 4.0, file system is NTFS as needed for File.Encryption
method.
Please copy and paste my code to see if you can maybe spot the error. Perhaps I am missing something. Please help.
Upvotes: 1
Views: 1344
Reputation: 2320
Are you using Windows 7 Home Edition?
In Windows 7 Home Edition, it is not supported. http://www.pcreview.co.uk/forums/encrypt-contents-secure-data-greyed-out-t171160.html
Upvotes: 2
Reputation: 2320
Your code works on my computer running Visual Studio 2010 in a WPF App 4.0 client profile. So it must be something with your user account and permissions. Try to save the file in another directory like the IsolatedStorage
Upvotes: 0