Click here to Skip to main content
15,302,644 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I get this problem all the time,

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.UnauthorizedAccessException: Access to the path is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.__Error.WinIOError()
   at System.IO.File.InternalReplace(String sourceFileName, String destinationFileName, String destinationBackupFileName, Boolean ignoreMetadataErrors)
   at System.IO.File.Replace(String sourceFileName, String destinationFileName, String destinationBackupFileName)
   at Uninstaller2.Uninstall.btnZip_Click(Object sender, EventArgs e) in C:\Users\Daniel\documents\visual studio 2010\Projects\Uninstaller2\Uninstaller2\Uninstall.cs:line 375
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
    Assembly Version:
    Win32 Version: 4.0.30319.239 (RTMGDR.030319-2300)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    Assembly Version:
    Win32 Version:
    CodeBase: file:///C:/Users/Daniel/Desktop/Uninstaller/Uninstaller2.exe
    Assembly Version:
    Win32 Version: 4.0.30319.235 built by: RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    Assembly Version:
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    Assembly Version:
    Win32 Version: 4.0.30319.258 built by: RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    Assembly Version:
    Win32 Version:
    CodeBase: file:///C:/Users/Daniel/Desktop/Uninstaller/ZipForge.DLL
    Assembly Version:
    Win32 Version: 4.0.30319.233 built by: RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the section.
The application must also be compiled with debugging

For example:

    < jitDebugging="true" />

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

System.IO.File.Replace(v.FullName, temppathmoment + @"Minecraft\OMinecraft\", temppathmoment + @"MinecraftBackUP\" + v.Name + "_backup");

If anyone can help me put permissions, or something for this problem..
Bojjaiah 28-Feb-12 2:00am
i think permissions problem

set the permissions as a administrator (whos run the application user)
right click of the visual studio run as a administrotar give credentials and run the application to check it.

1 solution

I assume you want to replace a file with the file v. Your problem now is that the 2nd argument is a folder, and it should be the file you want to replace.

If you have a folder with with 2 files (a.txt and b.txt) and run this:
File.Replace("a.txt", "b.txt", "b_old.txt");

you will end up with b.txt(wich was called a.txt) and b_old.txt(the old b.txt).

If you goal is to just make a backup. I suggest using File.Copy().
System.IO.File.Copy(v.FullName, temppathmoment + @"MinecraftBackUP\" + v.Name + "_backup");

If not you need to put a path to a file, not a folder as the 2nd argument.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900