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

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.
 
T

Tom Porterfield

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top