Results 1 to 10 of 10

Thread: [Just One More ?]Open txt file Read Only

  1. #1

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    [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:
    1. Private Sub InfoMen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoMen.Click
    2.         Try
    3.             'Opens Readme file using ms notepad
    4.             Shell("notepad.exe " & "readme.txt")
    5.         Catch ereadme As SystemException
    6.             System.Windows.Forms.MessageBox.Show(ereadme.Message)
    7.         End Try
    8.     End Sub
    Last edited by FishGuy; Oct 3rd, 2005 at 08:35 AM.

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    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
    "The dark side clouds everything. Impossible to see the future is."

  3. #3
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    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.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  4. #4

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    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.

  5. #5
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Open txt file Read Only

    You could just change it to readonly when you finally deploy.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: [RESOLVED] Open txt file Read Only

    Thanks Guys

  8. #8

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    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.
    Attached Images Attached Images  

  9. #9

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: [Just One More ?]Open txt file Read Only

    I added the image so people can see my deployment project.

  10. #10
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    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:
    1. Private Sub InfoMen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoMen.Click
    2.         Try
    3.             'Opens Readme file using ms notepad
    4.             Shell("notepad.exe " & "readme.txt")
    5.         Catch ereadme As SystemException
    6.             System.Windows.Forms.MessageBox.Show(ereadme.Message)
    7.         End Try
    8.     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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width