Before starting the process, you must set the file attributes and then set them back when you open it.
Example:
var attributes = File.GetAttributes(path);
File.SetAttributes(filePath, attributes | FileAttributes.ReadOnly);
System.IO.Diagnostics.Process.Start(fileName);
File.SetAttributes(filePath, attributes);
Note. This will change the file attributes of the actual file , so keep that in mind.
source
share