C#, working with files, "Unauthorized Access"?

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-12-25T13:40:00Z Indexed on 2010/12/25 13:54 UTC
Read the original article Hit count: 149

Filed under:

Hi, I'm learning about opening and saving files with C# and it seems that vista won't let my program save to a file on the root of C:\ , unless I run it in administrator mode.

Any ideas how to allow my program to play around with whatever files it wants?

Thanks!

string name;

    private void button2_Click(object sender, EventArgs e) ///// OPEN /////
    {
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            name = openFileDialog1.FileName;
            textBox1.Clear();
            textBox1.Text = File.ReadAllText(name);
            textBox2.Text = name;
        }
    }



    private void button1_Click(object sender, EventArgs e) ///// SAVE /////
    {
            File.WriteAllText(name, textBox1.Text);
    }

© Stack Overflow or respective owner

Related posts about c#