how to remove "Read Only" from file on remote server

  • Thread starter Thread starter John Grandy
  • Start date Start date
J

John Grandy

How to remove "Read Only" status on a file on a remote server?

My goal is to delete the file, but

System.File.Delete(\\machine1\c$\folder1\file1.txt)

is giving me an "Access is denied" error.

My log-on account is member of MACHINE1's local Administrators group.
 
How to remove "Read Only" status on a file on a remote server?

My goal is to delete the file, but

System.File.Delete(\\machine1\c$\folder1\file1.txt)

is giving me an "Access is denied" error.

My log-on account is member of MACHINE1's local Administrators group.

To remove an attribute use System.IO.File.SetAttributes. Ex:

System.IO.FileAttributes atts =
System.IO.File.GetAttributes(@"\\machine1\c$\folder1\file1.txt");
atts &= ~System.IO.FileAttributes.ReadOnly;
System.IO.File.SetAttributes(@"\\machine1\c$\folder1\file1.txt", atts);
 
Back
Top