Ask a questionAsk a question
 

AnswerHide a .txt file.

  • Wednesday, November 04, 2009 8:54 PMtopcan5 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have a Windows app, which reads and writes to a flat file (.txt file). I don't want user to modify this file. What are my options? Thanks.

Answers

  • Wednesday, November 04, 2009 9:11 PMjinzai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    The simplest thing is to make the file read only. Hiding it will only protect you from the mildly curious. I have my systems set to show hidden files...that is not at all uncommon.
  • Wednesday, November 04, 2009 9:19 PMjwavila Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    how are you going to write to this file if you don't want it modified?



    you can set the File Attributes to ReadOnly, but...

    I guess you could check if the User is you, and if so set it to read/write. If not you set it to ReadOnly. Don't know if that would work, but worth a try

    see this link for setting the Attributes

    http://www.dreamincode.net/forums/showtopic31134.htm
  • Wednesday, November 04, 2009 9:55 PMkaymaf Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I have a Windows app, which reads and writes to a flat file (.txt file). I don't want user to modify this file. What are my options? Thanks.

    You should consider different method to protect file from tampering, Readonly and Hidden will not work because user can remove readonly attribute from file through properties. You can use resgistry or encrypt/encode the text before save to file. Also, you can put the text file in IsolatedStorage

    kaymaf
    If that what you want, take it. If not, ignored it and no complain

All Replies

  • Wednesday, November 04, 2009 8:58 PMShariqDON Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    i have a Idea Or suggession....
    You can Also Encrypt it...... With Text Replacement Method....

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/1e0c977f-d023-4e8f-b551-24e15108b4ab




    www.shariqdon.media.officelive.com
  • Wednesday, November 04, 2009 9:11 PMjinzai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    The simplest thing is to make the file read only. Hiding it will only protect you from the mildly curious. I have my systems set to show hidden files...that is not at all uncommon.
  • Wednesday, November 04, 2009 9:19 PMjwavila Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    how are you going to write to this file if you don't want it modified?



    you can set the File Attributes to ReadOnly, but...

    I guess you could check if the User is you, and if so set it to read/write. If not you set it to ReadOnly. Don't know if that would work, but worth a try

    see this link for setting the Attributes

    http://www.dreamincode.net/forums/showtopic31134.htm
  • Wednesday, November 04, 2009 9:41 PMBalaji Baskar Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    By Using VB.Net you can use following ways to secure your file to an extend. Either you can mark your file as ReadOnly, Hidden or as a System File.

    Dim attribute As System.IO.FileAttributes = IO.FileAttributes.Encrypted
    System.IO.File.SetAttributes("file1.txt", attribute)
    
    Dim attribute As System.IO.FileAttributes = IO.FileAttributes.Hidden
    System.IO.File.SetAttributes("file1.txt", attribute)
    
    Dim attribute As System.IO.FileAttributes = IO.FileAttributes.System
    System.IO.File.SetAttributes("file1.txt", attribute)
    
    

     


    Balaji Baskar [Please mark the post as answer if it answers your question]
  • Wednesday, November 04, 2009 9:55 PMkaymaf Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I have a Windows app, which reads and writes to a flat file (.txt file). I don't want user to modify this file. What are my options? Thanks.

    You should consider different method to protect file from tampering, Readonly and Hidden will not work because user can remove readonly attribute from file through properties. You can use resgistry or encrypt/encode the text before save to file. Also, you can put the text file in IsolatedStorage

    kaymaf
    If that what you want, take it. If not, ignored it and no complain
  • Wednesday, November 04, 2009 10:31 PMJohnWein Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hide it in an image using steganography.