[Just One More ?]Open txt file Read Only
I am using this code to open a text file. is there a way to make it open read only so the users cannot modify it.
VB Code:
Private Sub InfoMen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoMen.Click
Try
'Opens Readme file using ms notepad
Shell("notepad.exe " & "readme.txt")
Catch ereadme As SystemException
System.Windows.Forms.MessageBox.Show(ereadme.Message)
End Try
End Sub
Re: Open txt file Read Only
Use process class instead of shell.
And maybe modifiying the file atributes to read-only might work?
System.IO.File.SetAttributes()
Regards
Jorge
Re: Open txt file Read Only
If you would make the actual file read only, then you would also have the desired result. Right?
edit:
I see Asgorath has beaten me to the punch.
Re: Open txt file Read Only
Well as long as I can still edit it at design time? I am using it as a readme file to show version numbers and any other info for the user.
Re: Open txt file Read Only
You could just change it to readonly when you finally deploy.
Re: Open txt file Read Only
A Setup project allows you to specify the ReadOnly, Hidden and System attributes of a deployed file that are independent of those attributes of the original file.
Re: [RESOLVED] Open txt file Read Only
1 Attachment(s)
Re: [RESOLVED] Open txt file Read Only
Do I set it ondividually as a file or set the whole content files as read only?
The file is packaged up in one of the projects.
Re: [Just One More ?]Open txt file Read Only
I added the image so people can see my deployment project.
Re: [Just One More ?]Open txt file Read Only
Quote:
Originally Posted by FishGuy
I am using this code to open a text file. is there a way to make it open read only so the users cannot modify it.
VB Code:
Private Sub InfoMen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoMen.Click
Try
'Opens Readme file using ms notepad
Shell("notepad.exe " & "readme.txt")
Catch ereadme As SystemException
System.Windows.Forms.MessageBox.Show(ereadme.Message)
End Try
End Sub
if you want the user to just view the file instead of opening an external program like notepad, just add a form to the project with a textbox that has it's readonly property set to true and then just read in the file yourself
at least that's how i would do it, not too hard :)