For a one line solution (provided that the current user has access to change the attributes of the mentioned file) here is how I would do it:
VB.Net
Shell("attrib file.txt -r")
the negative sign means to remove
and the r
is for read-only.
if you want to remove other attributes as well you would do:
Shell("attrib file.txt -r -s -h -a")
That will remove the Read-Only, System-File, Hidden and Archive attributes.
if you want to give back these attributes, here is how:
Shell("attrib file.txt +r +s +h +a")
the order does not matter.
C#
Process.Start("cmd.exe", "attrib file.txt +r +s +h +a");
References