I have tried to solve this error for some time but I can not find the solution.
Code
public static void PermDirectory(string perms)
{
var directory = new DirectoryInfo(perms){ Attributes = FileAttributes.Normal };
foreach (var info in directory.GetFileSystemInfos("*", SearchOption.AllDirectories))
{
info.Attributes = FileAttributes.Normal;
}
}
public static void DeleteDirectory(string path)
{
var directory = new DirectoryInfo(path) { Attributes = FileAttributes.Normal };
foreach (var info in directory.GetFileSystemInfos("*", SearchOption.AllDirectories))
{
info.Attributes = FileAttributes.Normal;
}
directory.Delete(true);
}
....
if (Directory.Exists(dir_instancias_temp))
{
DeleteDirectory(dir_instancias_temp);
}
string perms = dir_instancias_skyblock;
PermDirectory(perms);
Directory.Move(dir_instancias_skyblock, dir_instancias_temp);
string path = dir_instancias_temp;
DeleteDirectory(path);
Error
System.IO.IOException: Access denied to the path 'C: \ Users \ gonfe \ Desktop \ launcher \ instances \ Skyblock'. at System.IO.Directory.InternalMove (String sourceDirName, String destDirName, Boolean checkHost) at System.IO.Directory.Move (String sourceDirName, String destDirName) at Launcher_Empire_Islands.page_server_skyblock_islands.page_server_skyblock_islands_Load (Object sender, EventArgs e) at System.Windows.Forms.UserControl.OnLoad (EventArgs e) at System.Windows.Forms.UserControl.OnCreateControl () at System.Windows.Forms.Control.CreateControl (Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl () at System.Windows.Forms.Control.SetVisibleCore (Boolean value) at System.Windows.Forms.Control.set_Visible (Boolean value) at Launcher_Empire_Islands.page_servidores.imagen_skyblock_islands_Click (Object sender, EventArgs e) at System.Windows.Forms.Control.OnClick (EventArgs e) at Bunifu.Framework.UI.BunifuImageButton.OnClick (EventArgs e) at System.Windows.Forms.Control.WmMouseUp (Message & m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.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)