System.UnauthorizedAccessException: Access to the path "..." is denied
<p>I have C# wpf installation done with .net using click once installation. All works fine. Then I have the following code which is part of the installed program:</p>

<pre><code>String destinationPath = System.Windows.Forms.Application.StartupPath + "\\" + fileName;
File.Copy(path, destinationPath, true);
this.DialogResult = true;
this.Close();
</code></pre>

<p>But I get this error:</p>

<blockquote>
  <p>System.UnauthorizedAccessException: Access to the path C:\user\pc\appdata\local\apps\2.0.......  is denied.</p>
  
  <p>at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
        at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)</p>
</blockquote>

<p>Is it a permission error or do I need to tweak something in my code?</p>

<p>What puzzles me is why the user is able to install the program using click once into that directory without any issues, but uploading a file to it doesn't work?</p>