I am creating a windows form application. for security reason i want to store licence information into a text file and want to encrypt it.
var serializer = new XmlSerializer(typeof(Licence));
var saveData = new Licence
{
ProductId = txtProductID.Text,
ProductKey = txtProductKey.Text,
CreatedDate = validate.CreationDate,
ExpireDate = validate.ExpireDate,
DaysLeft = validate.DaysLeft
};
using (var writeFile = File.OpenWrite("data.txt"))
{
serializer.Serialize(writeFile, saveData);
}
using this code i can able to create text file successfully. but when i publish this project and install it it gives me error. error message is...
Access to the path "C:\Program Files (x86)\WebenixSystem\Metro Whole Sale\data.txt" is denied.
************** Exception Text ************** System.UnauthorizedAccessException: Access to the path 'C:\Program Files (x86)\WebenixSystem\Metro Whole Sale\data.txt' is denied.
How can i resolve this issue, and how can i encrypt this txt file? please help...