I wrote a program that copies all files from a certain folder to a folder on the C: drive, and it works perfectly fine on my own PC. But when I run it on another computer, it seems to only copy some of the files, and leaves the rest.
The stuff that I'm copying is in the same directory as the executable, but in a subfolder called "misc".
It collects all file directories in a string array, and uses File.Copy
to copy them.
Here is the code that I have:
// Create directory
Directory.CreateDirectory("c:\\subtool\\Controller");
string dest = "c:\\subtool\\Controller\\";
// Get all files from the misc folder
string[] files = Directory.GetFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).Replace("\\subtool.exe", "") + "\\misc");
// Cycle through all files in the misc folder and copy them to destination folder "dest"
foreach (string path in files)
{
System.IO.File.Copy(path, dest + Path.GetFileName(path), true);
}
When I run it on my main PC it runs fine, no errors. It also works when running outside of Visual Studio. However, when I run it on my laptop, it doesn't copy the files. What is this caused by?