No permissions writing to file
<p>I know there's lots of answers relating to this question but I've not come across a solution yet.</p>

<p>This is a WPF application, which runs from my desktop and I am the only user of this computer.</p>

<p>I've tried saving to desktop, TEMP, C:, <code>Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)</code></p>

<p>But none of the directories I've tried is working, so I'm a bit lost/confused.</p>

<pre><code>FileStream file = new FileStream("C:\\Users\\&lt;username&gt;\\AppData\\Local\\Temp",FileMode.OpenOrCreate, 
                  FileAccess.Write, 
                  FileShare.ReadWrite);

StreamWriter sr = new StreamWriter(file);
sr.WriteLine(data);

sr.Close();
</code></pre>

<p>Edit:</p>

<p>Code error, sorry, I figured it now:</p>

<pre><code>StreamWriter sr = new StreamWriter("C:\\Users\\Mike\\AppData\\Local\\Temp\\test.txt");
sr.WriteLine(data);
sr.Close();
</code></pre>
