Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read only attributes on files 1

Status
Not open for further replies.

golcarlad

Programmer
Nov 23, 2004
232
GB
How do you programatically remove the "read-only" attribute from a file in a certain directory. I know in VB - I used a shell command in VB - but I suppose there is a more elegant way in C#.
 
this should work
Code:
using System.IO;

File.SetAttributes("C:\\file.txt", FileAttributes.Normal);

Though that will remove ALL attributes. For example if the read only file is alos Hidden and a system file, those attributes will be wiped out.

If you want to get more specific, google for "C# System.IO.FileAttributes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top