title: How to make a "Read only" file?
body: <p>I'm using the C# <code>StreamWritier</code> class. Questions:</p>
  
  <ol>
  <li>How can I make a file read-only, so that no one can delete or write to it? </li>
  <li>How can I make a hidden file?</li>
  </ol>
  
  <p>I'm creating the file like so:</p>
  
  <pre><code>    private void button1_Click(object sender, EventArgs e)
      {
          SaveFileDialog save = new SaveFileDialog();
          save.FileName = textBox1.Text;
          save.Filter = "Text File | *.rtf";
  
  
          if (save.ShowDialog() == DialogResult.OK)
          {
              StreamWriter writer = new StreamWriter(save.OpenFile());
              writer.WriteLine(textBox2.Text);
          }
  
          writer.Dispose();
          writer.Close();
      }
  </code></pre>