I suggest you set the Read Only Attribute using the File.SetAttributes method.
To Set the file as Read Only:
File.SetAttributes(@"C:\Users\Owner\Desktop\file.txt", FileAttributes.ReadOnly);
To Set the file back to normal:
File.SetAttributes(@"C:\Users\Owner\Desktop\file.txt", FileAttributes.Normal);
You can check to see if the file is read only, and then throw an error :
System.IO.FileInfo fileInfo = new System.IO.FileInfo(@"C:\Users\Owner\Desktop\file.txt");
if (fileInfo.IsReadOnly)
{
//...Alert user that this file cannot be deleted
}
else
{
//... Delete the file here
}