I need to write a small console program for copying some content to AppData/Local.
As a source, I have a folder with a space in it. Lets call it "My Folder". My folder contains subfolders and other content.
So I have ./MyFolder and I need to copy it to C:\Users\Name\AppData\Local\My Folder
Now, what I have Done:
I know, that My Folder exists in ./
I can access AppData, because before copying, I need to remove some old trashy My Folder created earlier.
I have Administrator rights.
And now, I have this code snippet:
Process process = new Process();
process.StartInfo.FileName = "xcopy";
string stringsource = @"./My Folder";
string stringdestination = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string all = stringsource + " " + stringdestination + " /e /h /c /I";
/*this is for testing, resulting in CORRECT string path*/
Console.WriteLine(all);
process.StartInfo.Arguments = all;
process.Start();
This is in try/catch block and results with no error. But in destination AppData/Local, there is no new My Folder.
I have also tried:
string stringsource = "./My Folder";
string all = @""+stringsource + " " + stringdestination + " / e / h / c / I";
I have also tried:
process.StartInfo.Arguments = @"./My Folder "+Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)+ / e / h / c / I";
I have also tried:
process.StartInfo.Arguments = @"'./My Folder' "+Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)+ / e / h / c / I";
none of them worked. even with no error during copying, no content is actually copied. What is wrong here please?