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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Read-Only Text File 2

Status
Not open for further replies.

Becks25Not

Programmer
Jun 23, 2004
176
US
Hi Guys,

I have an application that I have to create a log file of events. I want to make the log file read only so the users can't change it. Any ideas?

Thanks in advanced.
Becca
 
Just use the file.setattributes method
You could even hide the file if you needed to
Code:
Dim f As System.IO.File
f.SetAttributes("c:\log.txt", IO.FileAttributes.ReadOnly)


Sweep
...if it works dont mess with it
 
You'll have to create it normally, write to it, close it and set its readonly attribute the first time you use it.

Subsequently you'll have to remove the readonly attribute, add more data, close it and set the readonly attribute again.

Alternatively if you're using WINNT, W2K or XP you can just give yourself Full Control and everybody else only Read permission using NTFS security facilities.
 
Thank you both!! I keep thinking I'd have to do it when I created it!! Stars toall!! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top