Copy Files From Winform App to Directory

  • Thread starter Thread starter old_School
  • Start date Start date
O

old_School

Guest
I'm trying to build a installer for an app I made. I'm trying to copy files from installer app to a directory. Getting a file access denied error. I'm using Admin account.


1594355.png


Code:

//Remove Files & Folders
if (Directory.Exists(_AppData.InstallPath)) { Directory.Delete(_AppData.InstallPath); }

//Install Fresh Copy
string GameDirectory = Environment.CurrentDirectory + @"\Game";


private void Copy(string sourceDir, string targetDir)
{
Directory.CreateDirectory(targetDir);

foreach (var file in Directory.GetFiles(sourceDir))
{
File.Copy(file, Path.Combine(targetDir, Path.GetFileName(file)));
}

foreach (var directory in Directory.GetDirectories(sourceDir))
{
Copy(directory, Path.Combine(targetDir, Path.GetFileName(directory)));
}

System.Threading.Thread.Sleep(500);
pbInstall.Visible = false;
}

Continue reading...
 
Back
Top