title: Protecting a file by a password
body: <p>I have a C# application in which i'd like to create a file :</p>
  
  <pre><code>   string fileName = "test.txt";  // a sample file name
          // Delete the file if it exists.
          if (System.IO.File.Exists(fileName))
          {
              System.IO.File.Delete(fileName);
          }
         // Create the file.
          using (System.IO.FileStream fs = System.IO.File.Create(fileName, 1024))
          {
              // Add some information to the file.
              byte[] info = new System.Text.UTF8Encoding(true).GetBytes("This is some text in the file.");
              fs.Write(info, 0, info.Length);
          }
  
  
          string s = "";
          using (System.IO.StreamReader sr = System.IO.File.OpenText(fileName))
          {
  
              while ((s = sr.ReadLine()) != null)
              {
                  textBox1.Text += s;
              }
          }
  </code></pre>
  
  <p>i need to protect the file by a password outside the program and the file is accessible inside the program without password.</p>
  
  <p>How can i change the snippet to do this task?</p>