How to make the file unreadable RRS feed

  • Question

  • Hi,

     Iam writing a text file in C# Windows form in a folder, when user tries to open in any worpad,notepad, IE, it should not be opened. And also am reding that same file to save in desired location

    • Moved by Paul Zhou Monday, January 9, 2012 5:38 AM (From:.NET Platform Architecture Development Discussions)
    Saturday, January 7, 2012 2:31 PM


All replies

  • Can you elaborate a little more about your issue.

    1. Why do you want to prevent this file being opened by other applications ?

    2. This prevention is while your application is accessing this file, or even after your application is closed ?

    Saturday, January 7, 2012 2:57 PM
  • All files have permissions. You can remove the read permission from the user/group you don't reading the file.
    Sunday, January 8, 2012 3:13 AM
  • Hello,

    Instead of revoke access to other application, you can encrypt the file content, so that other than your application does not access or understand any information from the file.

    Hope, this will help you out.





    If this post answers your question, please click Mark As Answer. If this post is helpful please click Mark as Helpful.
    Monday, January 9, 2012 9:46 AM
  • Yes, but how do you encrypt the file content?


    Nevin Janzen -- If this post answers your question, please click Propose As Answer. If this post is helpful, please click Vote As Helpful. Thanks!
    Tuesday, January 10, 2012 12:35 AM
  • http://support.microsoft.com/kb/307010 and  http://www.codeproject.com/KB/files/encryption.aspx  are a good starting point (of course securing the keys could be a problem).

    However if you you just want to prevent modification then you could look at signing the file with a private key and then verifying it with a public key. If it has been modified it will not match the signature (which only you can create with your private key) and you can reject the file. 

    e.g. http://stackoverflow.com/questions/3944265/how-can-sign-a-file-with-bouncycastle-dll-in-c-sharp




    • Marked as answer by Paul Zhou Monday, January 16, 2012 4:34 AM
    Tuesday, January 10, 2012 2:10 AM