Closed PCAssistSoftware closed 2 years ago
OK, according to @PCAssistSoftware description I tried to make a copy with my app, with the BackupApp and with RoboCopy. My results were identical if I use RoboSharp. According to my tests, it is not a RoboCopy problem.
In my tests, only the program directory of the started program (my app or BackupApp) was copied.
@PCAssistSoftware: Please check the log file and here exactly the source directory. I could see that in this case the source directory points to the start directory of the copy program!
@PCAssistSoftware: Please check the log file and here exactly the source directory. I could see that in this case the source directory points to the start directory of the copy program!
Yes same here, good spot - and thanks for testing for me - thought I was going mad!
@RFBomb @tjscience - any thoughts on this
I checked all the functions that change the source directory, because I noticed during a debug that "C: \" results in "C:". In "ExtensionMethods.cs", the "CleanDirectoryPath" method deletes all backslashes that are at the end of a path. That is absolutely correct, but not if you already have the root directory here. I also don't think that a normal path with a backslash at the end would be wrong.
// Get rid of trailing Directory Seperator Chars
while(path.Length > 0 && (path.EndsWith(Path.DirectorySeparatorChar.ToString()) || path.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
{
path = path.Substring(0, path.Length - 1);
}
"C:" is interpreted here as the start directory of the program, which was also carried out correctly by RoboCopy. Since the change in the path also affects the target directory, problems will also arise when copying to a root directory.
Maybe include another condition in that function:
path.length > 0 && path != System.IO.Path.GetPathRoot(path)
On Sun, Dec 5, 2021 at 4:50 AM JoE-Seeve @.***> wrote:
I checked all the functions that change the source directory, because I noticed during a debug that "C: \" results in "C:". In "ExtensionMethods.cs", the "CleanDirectoryPath" method deletes all backslashes that are at the end of a path. That is absolutely correct, but not if you already have the root directory here. I also don't think that a normal path with a backslash at the end would be wrong.
// Get rid of trailing Directory Seperator Chars while(path.Length > 0 && (path.EndsWith(Path.DirectorySeparatorChar.ToString()) || path.EndsWith(Path.AltDirectorySeparatorChar.ToString()))) { path = path.Substring(0, path.Length - 1); }
"C:" is interpreted here as the start directory of the program, which was also carried out correctly by RoboCopy.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tjscience/RoboSharp/issues/116#issuecomment-986198623, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE34HFZEUV3JQVWZUVDUEPLUPMYYHANCNFSM5JLZ2MLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Thanks for your responses
@RFBomb
If you mean changing
while(path.Length > 0 && (path.EndsWith(Path.DirectorySeparatorChar.ToString()) || path.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
to
while(path.Length > 0 && path != System.IO.Path.GetPathRoot(path) && (path.EndsWith(Path.DirectorySeparatorChar.ToString()) || path.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
Then i'm afraid that doesn't work - it results in error below:
ERROR : Invalid Parameter #1 : "E:" C:\Users\darre\Desktop\2 *.* /COPY:DAT /DCOPY:DA /E /ZB /R:2 /W:2 /L /NJH /BYTES /L"
That confuses me how that’s happening, if all that function does is remove ending slashes from a path.
(I’ve only looked at the issue thread, not code).
Is the goal to have ‘E:’ or ‘E:\’ in this scenario?
On Sun, Dec 5, 2021 at 8:09 AM Darren Rose @.***> wrote:
Thanks for your responses
@RFBomb https://github.com/RFBomb
If you mean changing
while(path.Length > 0 && (path.EndsWith(Path.DirectorySeparatorChar.ToString()) || path.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
to
while(path.Length > 0 && path != System.IO.Path.GetPathRoot(path) && (path.EndsWith(Path.DirectorySeparatorChar.ToString()) || path.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
Then i'm afraid that doesn't work as it seems to remove the quotes from the destination path and file filter in the command string e.g.
"E:" "C:\Users\darre\Desktop\2" "." /COPY:DAT /DCOPY:DA /E /ZB /R:2 /W:2 /L /NJH /BYTES becomes
"E:" C:\Users\darre\Desktop\2 . /COPY:DAT /DCOPY:DA /E /ZB /R:2 /W:2 /L /NJH /BYTES"
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tjscience/RoboSharp/issues/116#issuecomment-986227556, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE34HF6UG3SZ2O4QP3QRJULUPNQCPANCNFSM5JLZ2MLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Okay done some testing just using RoboCopy from command line - and you can't have E:\ as source only E: as if not you get:
ERROR : Invalid Parameter #1 : "E:" C:\Users\darre\Desktop\2 *.* /COPY:DAT /DCOPY:DA /E /ZB /R:2 /W:2 /L /NJH /BYTES /L"
Which is same error I get in log if making your suggested change above - so think my initial response about quotes was incorrect
So it is possibly not an issue at all with the "CleanDirectoryPath" method
Then it’s likely an issue where the executable, which is in-use, is attempting to copy itself somewhere, which may flake out the copy operation.
What if you ignore the executable file /containing folder in the robocopy command?
On Sun, Dec 5, 2021 at 8:32 AM Darren Rose @.***> wrote:
Okay done some testing just using RoboCopy from command line - and you can't have E:\ as source only E: as if not you get:
ERROR : Invalid Parameter #1 : "E:" C:\Users\darre\Desktop\2 . /COPY:DAT /DCOPY:DA /E /ZB /R:2 /W:2 /L /NJH /BYTES /L"
Which is same error I get in log if making your suggested change above - so think my initial response about quotes was incorrect
So it is possibly not an issue at all with the "CleanDirectoryPath" method
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tjscience/RoboSharp/issues/116#issuecomment-986231127, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE34HF4CUJCBJBMJO6M5GPDUPNSVXANCNFSM5JLZ2MLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
No that doesn't help - for some reason it still only sees program directory as source despite source being set - log output below:
Started : 05 December 2021 14:09:29
Source : E:
Destination : C:\Users\darre\Desktop\2
Command Line : "E:" "C:\Users\darre\Desktop\2" "*.*" /COPY:DAT /DCOPY:DA /E /ZB /XD "E:\Programming\Visual Basic\Apps Developed\RoboCopy GUI\RoboCopy GUI\bin\Debug" /R:2 /W:2 /L /NJH /BYTES
------------------------------------------------------------------------------
6 E:\Programming\Visual Basic\Apps Developed\RoboCopy GUI\RoboCopy GUI\bin\Debug\
New File 323400 RoboCopy GUI.exe
New File 1365 RoboCopy GUI.exe.config
New File 130560 RoboCopy GUI.pdb
New File 683 RoboCopy GUI.xml
New File 61440 RoboSharp.dll
New File 49059 RoboSharp.xml
New Dir 0 E:\Programming\Visual Basic\Apps Developed\RoboCopy GUI\RoboCopy GUI\bin\Debug\Logs\
------------------------------------------------------------------------------
Finished : 05 December 2021 14:09:30
Very odd.
If you were to copy RoboCopy.exe to the E drive in the same folder, and run that via command line, does the issue not occur?
I’d test this, but it’s outside my use case (and I’m off the clock right now). Good luck
On Sun, Dec 5, 2021 at 9:10 AM Darren Rose @.***> wrote:
No that doesn't help - for some reason it still only sees program directory as source despite source being set - log output below:
Started : 05 December 2021 14:09:29
Source : E: Destination : C:\Users\darre\Desktop\2
Command Line : "E:" "C:\Users\darre\Desktop\2" "." /COPY:DAT /DCOPY:DA /E /ZB /XD "E:\Programming\Visual Basic\Apps Developed\RoboCopy GUI\RoboCopy GUI\bin\Debug" /R:2 /W:2 /L /NJH /BYTES
6 E:\Programming\Visual Basic\Apps Developed\RoboCopy GUI\RoboCopy GUI\bin\Debug\ New File 323400 RoboCopy GUI.exe New File 1365 RoboCopy GUI.exe.config New File 130560 RoboCopy GUI.pdb New File 683 RoboCopy GUI.xml New File 61440 RoboSharp.dll New File 49059 RoboSharp.xml New Dir 0 E:\Programming\Visual Basic\Apps Developed\RoboCopy GUI\RoboCopy GUI\bin\Debug\Logs\
Finished : 05 December 2021 14:09:30
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tjscience/RoboSharp/issues/116#issuecomment-986237173, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE34HF5GND24JJ7RIETU2IDUPNXHHANCNFSM5JLZ2MLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
I have made some tests with RoboCopy and here are the results:
TEST 1: Parameters are OK but the source and directory for RoboCopy look strange Microsoft Windows [Version 10.0.19044.1387] (c) Microsoft Corporation. Alle Rechte vorbehalten.
C:\WINDOWS\system32>robocopy "C:\" "C:\Users\Admin\Downloads\iNetBackup-Tests" /DCOPY:DA
Gestartet: Sonntag, 5. Dezember 2021 16:09:00 Quelle : C:\WINDOWS\system32\" C:\Users\Admin\Downloads\iNetBackup-Tests \DCOPY:DA\ Ziel -
Dateien : *.*
Optionen: . /DCOPY:DA /COPY:DAT /R:1000000 /W:30
FEHLER: Es wurde kein Zielverzeichnis angegeben.
Einfache Syntax :: ROBOCOPY Quelle Ziel /MIR
Quelle :: Quellverzeichnis (Laufwerk:\Pfad oder
\\Server\Freigabe\Pfad)
Ziel :: Zielverzeichnis (Laufwerk:\Pfad oder
\\Server\Freigabe\Pfad)
/MIR :: Spiegelt eine vollständige Verzeichnisstruktur.
Weitere Informationen erhalten Sie über den Befehl "ROBOCOPY /?"
**** Der Befehl "/MIR" kann Dateien sowohl kopieren als auch LÖSCHEN.
C:\WINDOWS\system32>
Test 2: Source with double slash and now RoboCopy with correct source directory Microsoft Windows [Version 10.0.19044.1387] (c) Microsoft Corporation. Alle Rechte vorbehalten.
C:\WINDOWS\system32>RoboCopy "C:\" "C:\Users\Admin\Downloads\iNetBackup-Tests" /DCOPY:DA
Gestartet: Sonntag, 5. Dezember 2021 16:14:12 Quelle : C:\ Ziel : C:\Users\Admin\Downloads\iNetBackup-Tests\
Dateien : *.*
Optionen: . /DCOPY:DA /COPY:DAT /R:1000000 /W:30
4 C:\
*EXTRA Datei 65536 ntuser.dat{50146924-c1e6-11eb-9971-38afd7a01fd2}.TM.blf
*EXTRA Datei 524288 ntuser.dat{50146924-c1e6-11eb-9971-38afd7a01fd2}.TMContainer00000000000000000001.regtrans-ms
*EXTRA Datei 524288 ntuser.dat{50146924-c1e6-11eb-9971-38afd7a01fd2}.TMContainer00000000000000000002.regtrans-ms
*EXTRA Datei 65536 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TM.blf
*EXTRA Datei 524288 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TMContainer00000000000000000001.regtrans-ms
*EXTRA Datei 524288 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TMContainer00000000000000000002.regtrans-ms
*EXTRA Datei 65536 ntuser.dat{55a747d4-4e78-11eb-9941-38afd7a01fd2}.TM.blf
*EXTRA Datei 524288 ntuser.dat{55a747d4-4e78-11eb-9941-38afd7a01fd2}.TMContainer00000000000000000001.regtrans-ms
*EXTRA Datei 524288 ntuser.dat{55a747d4-4e78-11eb-9941-38afd7a01fd2}.TMContainer00000000000000000002.regtrans-ms
*EXTRA Datei 65536 ntuser.dat{ae030f4c-5e28-11eb-9944-38afd7a01fd2}.TM.blf
*EXTRA Datei 524288 ntuser.dat{ae030f4c-5e28-11eb-9944-38afd7a01fd2}.TMContainer00000000000000000001.regtrans-ms
*EXTRA Datei 524288 ntuser.dat{ae030f4c-5e28-11eb-9944-38afd7a01fd2}.TMContainer00000000000000000002.regtrans-ms
*EXTRA Datei 20 ntuser.ini
Neue Datei 8192 DumpStack.log.tmp
2021/12/05 16:14:12 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\DumpStack.log.tmp Das System kann die angegebene Datei nicht finden.
Neue Datei 7.9 g hiberfil.sys
2021/12/05 16:14:12 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\hiberfil.sys Das System kann die angegebene Datei nicht finden.
Neue Datei 3.0 g pagefile.sys
2021/12/05 16:14:12 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\pagefile.sys Das System kann die angegebene Datei nicht finden.
Neue Datei 16.0 m swapfile.sys
2021/12/05 16:14:12 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\swapfile.sys Das System kann die angegebene Datei nicht finden.
Insgesamt KopiertÜbersprungenKeine Übereinstimmung FEHLER Extras
Verzeich.: 1 0 1 0 0 0 Dateien: 4 0 0 0 4 13 Bytes: 10.971 g 0 0 0 10.971 g 4.25 m Zeiten: 0:00:00 0:00:00 0:00:00 0:00:00 Beendet: Sonntag, 5. Dezember 2021 16:14:12
C:\WINDOWS\system32>
I meant actually copying the robocopy executable onto the E drive into the same folder as your gui’s executable and calling it from there using the same command your gui generated.
I’d imagine that attempting to do the C:/ drive would produce odd results. But (I can’t read what looks like German, so my translation may be wrong) it appears that using C: in the command used robocopy’s executable folder as the source, while C:\ got the desired results.
On Sun, Dec 5, 2021 at 10:16 AM JoE-Seeve @.***> wrote:
I have made some tests with RoboCopy and here are the results:
TEST 1: Parameters are OK but the source and directory for RoboCopy look strange Microsoft Windows [Version 10.0.19044.1387] (c) Microsoft Corporation. Alle Rechte vorbehalten.
C:\WINDOWS\system32>robocopy "C:" "C:\Users\Admin\Downloads\iNetBackup-Tests" /DCOPY:DA
ROBOCOPY :: Robustes Dateikopieren für Windows
Gestartet: Sonntag, 5. Dezember 2021 16:09:00 Quelle : C:\WINDOWS\system32" C:\Users\Admin\Downloads\iNetBackup-Tests \DCOPY:DA Ziel -
Dateien : .
Optionen: . /DCOPY:DA /COPY:DAT /R:1000000 /W:30
FEHLER: Es wurde kein Zielverzeichnis angegeben.
Einfache Syntax :: ROBOCOPY Quelle Ziel /MIR
Quelle :: Quellverzeichnis (Laufwerk:\Pfad oder \\Server\Freigabe\Pfad) Ziel :: Zielverzeichnis (Laufwerk:\Pfad oder \\Server\Freigabe\Pfad) /MIR :: Spiegelt eine vollständige Verzeichnisstruktur.
Weitere Informationen erhalten Sie über den Befehl "ROBOCOPY /?"
**** Der Befehl "/MIR" kann Dateien sowohl kopieren als auch LÖSCHEN.
C:\WINDOWS\system32>
Test 2: Source with double slash and now RoboCopy with correct source directory Microsoft Windows [Version 10.0.19044.1387] (c) Microsoft Corporation. Alle Rechte vorbehalten.
C:\WINDOWS\system32>RoboCopy "C:\" "C:\Users\Admin\Downloads\iNetBackup-Tests" /DCOPY:DA
ROBOCOPY :: Robustes Dateikopieren für Windows
Gestartet: Sonntag, 5. Dezember 2021 16:14:12 Quelle : C: Ziel : C:\Users\Admin\Downloads\iNetBackup-Tests\
Dateien : .
Optionen: . /DCOPY:DA /COPY:DAT /R:1000000 /W:30
4 C:\ *EXTRA Datei 65536 ntuser.dat{50146924-c1e6-11eb-9971-38afd7a01fd2}.TM.blf *EXTRA Datei 524288 ntuser.dat{50146924-c1e6-11eb-9971-38afd7a01fd2}.TMContainer00000000000000000001.regtrans-ms *EXTRA Datei 524288 ntuser.dat{50146924-c1e6-11eb-9971-38afd7a01fd2}.TMContainer00000000000000000002.regtrans-ms *EXTRA Datei 65536 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TM.blf *EXTRA Datei 524288 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TMContainer00000000000000000001.regtrans-ms *EXTRA Datei 524288 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TMContainer00000000000000000002.regtrans-ms *EXTRA Datei 65536 ntuser.dat{55a747d4-4e78-11eb-9941-38afd7a01fd2}.TM.blf *EXTRA Datei 524288 ntuser.dat{55a747d4-4e78-11eb-9941-38afd7a01fd2}.TMContainer00000000000000000001.regtrans-ms *EXTRA Datei 524288 ntuser.dat{55a747d4-4e78-11eb-9941-38afd7a01fd2}.TMContainer00000000000000000002.regtrans-ms *EXTRA Datei 65536 ntuser.dat{ae030f4c-5e28-11eb-9944-38afd7a01fd2}.TM.blf *EXTRA Datei 524288 ntuser.dat{ae030f4c-5e28-11eb-9944-38afd7a01fd2}.TMContainer00000000000000000001.regtrans-ms *EXTRA Datei 524288 ntuser.dat{ae030f4c-5e28-11eb-9944-38afd7a01fd2}.TMContainer00000000000000000002.regtrans-ms *EXTRA Datei 20 ntuser.ini Neue Datei 8192 DumpStack.log.tmp
2021/12/05 16:14:12 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\DumpStack.log.tmp Das System kann die angegebene Datei nicht finden.
Neue Datei 7.9 g hiberfil.sys
2021/12/05 16:14:12 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\hiberfil.sys Das System kann die angegebene Datei nicht finden.
Neue Datei 3.0 g pagefile.sys
2021/12/05 16:14:12 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\pagefile.sys Das System kann die angegebene Datei nicht finden.
Neue Datei 16.0 m swapfile.sys
2021/12/05 16:14:12 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\swapfile.sys Das System kann die angegebene Datei nicht finden.
Insgesamt KopiertÜbersprungenKeine Übereinstimmung FEHLER Extras
Verzeich.: 1 0 1 0 0 0 Dateien: 4 0 0 0 4 13 Bytes: 10.971 g 0 0 0 10.971 g 4.25 m Zeiten: 0:00:00 0:00:00 0:00:00 0:00:00 Beendet: Sonntag, 5. Dezember 2021 16:14:12
C:\WINDOWS\system32>
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tjscience/RoboSharp/issues/116#issuecomment-986248125, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE34HF7UQUQA5NDZVVUULKLUPN66PANCNFSM5JLZ2MLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
... and here is the thisrd test. Please have a look at the RoboCopy parameter lina and the Source Directory in the start log:
Microsoft Windows [Version 10.0.19044.1387] (c) Microsoft Corporation. Alle Rechte vorbehalten.
C:\WINDOWS\system32>RoboCopy "C:\temp.." "C:\Users\Admin\Downloads\iNetBackup-Tests" /DCOPY:DA
Gestartet: Sonntag, 5. Dezember 2021 16:29:22 Quelle : C:\ Ziel : C:\Users\Admin\Downloads\iNetBackup-Tests\
Dateien : *.*
Optionen: . /DCOPY:DA /COPY:DAT /R:1000000 /W:30
4 C:\
*EXTRA Datei 65536 ntuser.dat{50146924-c1e6-11eb-9971-38afd7a01fd2}.TM.blf
*EXTRA Datei 524288 ntuser.dat{50146924-c1e6-11eb-9971-38afd7a01fd2}.TMContainer00000000000000000001.regtrans-ms
*EXTRA Datei 524288 ntuser.dat{50146924-c1e6-11eb-9971-38afd7a01fd2}.TMContainer00000000000000000002.regtrans-ms
*EXTRA Datei 65536 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TM.blf
*EXTRA Datei 524288 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TMContainer00000000000000000001.regtrans-ms
*EXTRA Datei 524288 NTUSER.DAT{53b39e88-18c4-11ea-a811-000d3aa4692b}.TMContainer00000000000000000002.regtrans-ms
*EXTRA Datei 65536 ntuser.dat{55a747d4-4e78-11eb-9941-38afd7a01fd2}.TM.blf
*EXTRA Datei 524288 ntuser.dat{55a747d4-4e78-11eb-9941-38afd7a01fd2}.TMContainer00000000000000000001.regtrans-ms
*EXTRA Datei 524288 ntuser.dat{55a747d4-4e78-11eb-9941-38afd7a01fd2}.TMContainer00000000000000000002.regtrans-ms
*EXTRA Datei 65536 ntuser.dat{ae030f4c-5e28-11eb-9944-38afd7a01fd2}.TM.blf
*EXTRA Datei 524288 ntuser.dat{ae030f4c-5e28-11eb-9944-38afd7a01fd2}.TMContainer00000000000000000001.regtrans-ms
*EXTRA Datei 524288 ntuser.dat{ae030f4c-5e28-11eb-9944-38afd7a01fd2}.TMContainer00000000000000000002.regtrans-ms
*EXTRA Datei 20 ntuser.ini
Neue Datei 8192 DumpStack.log.tmp
2021/12/05 16:29:22 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\DumpStack.log.tmp Das System kann die angegebene Datei nicht finden.
Neue Datei 7.9 g hiberfil.sys
2021/12/05 16:29:22 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\hiberfil.sys Das System kann die angegebene Datei nicht finden.
Neue Datei 3.0 g pagefile.sys
2021/12/05 16:29:22 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\pagefile.sys Das System kann die angegebene Datei nicht finden.
Neue Datei 16.0 m swapfile.sys
2021/12/05 16:29:22 FEHLER 2 (0x00000002) Dateiattribute werden geändert C:\swapfile.sys Das System kann die angegebene Datei nicht finden.
Insgesamt KopiertÜbersprungenKeine Übereinstimmung FEHLER Extras
Verzeich.: 1 0 1 0 0 0 Dateien: 4 0 0 0 4 13 Bytes: 10.971 g 0 0 0 10.971 g 4.25 m Zeiten: 0:00:00 0:00:00 0:00:00 0:00:00 Beendet: Sonntag, 5. Dezember 2021 16:29:22
C:\WINDOWS\system32>RoboCopy "C:\temp.." "C:\Users\Admin\Downloads\iNetBackup-Tests" /DCOPY:DA
@JoE-Seeve - not sure what I am looking at as can't translate language in results - but I had already done some tests with / without trailing slashes as above and RoboCopy doesn't support trailing slash so has to be C: and not C:\ - so personally don't think this has anything to do with it.
Following from @RFBomb suggestion above I tried running RoboCopy from same directory and whilst doing this did discover something that replicates the problem but hard to explain - hopefully below makes sense
All tests from admin command prompt
1)
prompt currently shows active directory as C:\Windows\System32>
robocopy "E:" "C:\Users\darre\Desktop\2" "*.*" /COPY:DAT /DCOPY:DA /E /ZB /R:2 /W:2 /L /NJH /BYTES /L
and it works fine
2)
change active directory to E:
and it again works fine
3)
Change active directory to E:\Programming\Visual Basic\Apps Developed\RoboCopy GUI\RoboCopy GUI\bin\Debug>
and it FAILS to work - only doing current folder not chosen source
4)
BUT if it now change active directory back to C:
it still FAILS - so it appears it has something to do with what the current active path is set to for a drive even if that is not the current drive
5)
Go back to E:, do CD E:\, change back to C: and run it and now works fine
Summary
So problem appears to be RoboCopy rather than RoboSharp - and relates to currently active working directory
Potential solution
This seems to work for me when quickly testing
Before running RoboCommand.Start
or RoboCommand.StartAsync
change the CurrentDirectory to be the same as the chosen Source directory e.g.
My.Computer.FileSystem.CurrentDirectory = Source
N.B. The solution may differ for others as also discovered issue in sample Backup App relating to trailing slashes which can cause problems - discussed in more detail here #117
@PCAssistSoftware That is pretty much what I had expected you would find. Good job investigating it. I assumed it had something to do with the working directory, but couldn’t think of the phrase. Hence my suggestion to move robocopy to that dir.
Does robosharp call robocopy via a command prompt, or run it directly as a process? If it’s via command prompt, maybe a command to set the active directly to the root can be called prior to executing the robocopy command. Or maybe a command to set the working directory of the thread.
Doing a PR with that may harm usability. It would depend if the affects the calling application as well, or just the robosharp dll
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setcurrentdirectory
The current directory is shared by all threads of the process: If one thread changes the current directory, it affects all threads in the process. Multithreaded applications and shared library code should avoid calling the SetCurrentDirectory function due to the risk of affecting relative path calculations being performed by other threads.
... the German comments are not important because the differences between the parameters and the resulting "Source Directory" are the important pointers.
It appears that RoboCopy is attempting to prevent an entire drive from being copied to that exact drive.
Source "C:\" in RoboCopy will result in strange "Source Directory" ->see test 1 Source "C:\" in RoboCopy gives the Source and Destinaton that you expect -> see test 2 Source "C:" in RoboCopy points to start directory of the copy app Source "C:\temp\.." points to the root directory -> see test 3
It appears that RoboCopy is attempting to prevent an entire drive from being copied to that exact drive. RoboCopy would keep finding new files at runtime and then never ends with such copying. For this reason, the area to be copied must not overlap with the target area.
@RFBomb
I will continue testing and respond later - certainly in my app it doesn't affect anything else so may be best to set this in your GUI or calling app rather than anywhere directly in RoboSharp.dll code
@JoE-Seeve
See my previous response, problem solved when setting .CurrentDirectory to same as source source - can copy any location without any problems at all once that change is made. Same as I replicated in command prompt by changing working directory.
I think the main problem with your tests is you are trying to copy C:... to C:... so that will always cause confusion - I had never tried copying from a source which contained the destination so to speak, it is always one drive to another e.g. C:\ to E:\backup, or if same drive something like c:\folder1 to c:\folder2 e.g. where source doesn't contain destination, which would confuse any copy / backup tool I suspect
@JoE-Seeve you seem to have triggered a different thing than what @PCAssistSoftware was trying to resolve.
@PCAssistSoftware - maybe this can be done into a PR as a purely optional (well documented with a summary tag) parameter in one of the classes. That way portable applications can set the value to true to avoid running into this issue, while non-portable applications can leave it with the default false.
But, as I had mentioned, it may cause more harm coding it in if doing multiple copy operations. But maybe that doesn’t matter once the robocopy command has been initiated.
As far as the summary tag, I think it would need to describe in detail the issue that it resolves, with a see href to the link I provided
Yes, I know that the solution suggested by @PCAssistSoftware only solves the problem with root directories without a slash. However, a general solution must be built in, as otherwise problems can also arise with the example application.
@RFBomb - just run multiple operations one after the other involving different source and destinations and it seemed to work fine.
But I do completely agree with what you are saying - perhaps for now I will just add it as a note to readme.md - perhaps a "known issues" section covering problem and potential solution because like you say it will probably be app and user specific as to whether needed or not.
To be fair I have been using RoboSharp for years to migrate data from old server to new server, and never came across it until yesterday!
@JoE-Seeve
Having a slash or not is NOT the problem or the solution as covered above - RoboCopy itself doesn't allow you to use trailing slashes either for source or destination (you get invalid parameter error), so the behaviour in RoboSharp is correct. Various articles cover the reasons for this e.g. https://superuser.com/questions/1544437/why-does-the-trailing-slash-on-the-target-confuse-robocopy
The issue I initially reported which I have hopefully found a fix for was it appears to do with what a drives working directory is set to and can be replicated as above using RoboCopy command line as well as RoboSharp
The separate not related to my original posted issue problem you found above is when trying to copy a source into a destination which contains the source - and from quick testing here causes problems with most other backup tools (and with standard .NET file copty methods) - in fact most of them actually stop you doing it and say your destination cannot contain your source - so this is a check we could add and warn for
@PCAssistSoftware: Why, I'm discussing the same problem that you have opened here?
@PCAssistSoftware: What happens if the user uses the "CurrentDirectory" to save data or changes it? Does the solution still work then? I think an application only has one "CurrentDirectory".
Originally posted by @ JoE-Seeve - wrongly deleted by @ PCAssistSoftware
The copy job shown in the following figure is copiying something but not as expected.
My response
Okay - I see your point....
Hadn't noticed it before as I don't use the included Backup App I use my own GUI and that works fine and doesn't have same issue, and for life of me I cannot see difference between how that app does it and how my app does it e.g. if I type in my app source box E: or E:\ it works fine either way as path gets the trailing \ removed, and all I am doing is setting .Source to text box content in same way.....
But in Backup App if I put breakpoint on line 62 I can see the value of copy.CopyOptions.Source is getting set to E:\ even though textbox shows E:\ - so somewhere it is adding an extra \ to the end - not sure if this is a C# thing as seeing it as an escape character? as my app is in VB - but that I belive could be issue.
Originally posted by @ JoE-Seeve - wrongly deleted by @ PCAssistSoftware
... and here are additional tests with the BackupApp. I want to copy the "C:" to "E:" (/MIR). The problem @PCAssistSoftware has described occur (source: "C:", "C:", C:\").
As a described before the correct copy job will be done with source "C:\temp.." because this points to C:\ and not to the start directory. The name of the directory which was given here as "temp" does not matter.
The problem occurs with all applications, including my app, when I want to copy a root directory and use a directory selection dialog to specify a standard root directory as the source (e.g. "C: "). I don't know why a new issue was opened here because it's exactly the same problem that was addressed in # 116!
My response
This may perhaps be relevant to the trailing quote issue, quote below from https://ss64.com/nt/robocopy.html - and does seem to be to do with escape character as I thought, and would explain difference between my app written in VB.NET and the sample Backup App in the project written in C# - as in VB.NET you don't need to escape a backslash.
"If either the source or desination are a "quoted long foldername" do not include a trailing backslash as this will be treated as an escape character, i.e. "C:\some path" will fail but "C:\some path\" or "C:\some path." or "C:\some path" will work."
Response from @ RFBomb copied from 117
backslashes are used as escape characters in C#. As such: C:\ == C:\ C:\temp == C:\temp C:\temp\subfolder == C:\temp\subfolder C:\temp\subfolder\etc == C:\temp\subfolder\etc
So a method that wants to the last subfolder/directory from a path may look like this:
string X = "C:\Some\Path\To\File.txt"; int i = X.LastIndexOf('\'); -> i will be equal to 15 return X.remove( i ); -> Returns "C:\Some\Path\To"
@PCAssistSoftware: What happens if the user uses the "CurrentDirectory" to save data or changes it? Does the solution still work then? I think an application only has one "CurrentDirectory".
I don't know yet - in my initial testing of changing CurrentDirectory it solves my initial issue and works fine and I haven't noticed any side effects. I tend to not reference CurrentDirectory in my own code when writing logs etc, I refer to location based on app path e.g. Application.ExecutablePath or Application.StartupPath
Does robosharp call robocopy via a command prompt, or run it directly as a process? ....
It runs it as a process - https://github.com/tjscience/RoboSharp/blob/8ed943539262c37c68c389a4338fa080555c4494/RoboSharp/RoboCommand.cs#L372
Perhaps setting the WorkingDirectory for the RoboCopy process here would be an option e.g. process.StartInfo.WorkingDirectory = copyOptions.Source;
EDIT: I can confirm the above change (process.StartInfo.WorkingDirectory) does NOT fix the issue, so it seems to be to do with the location the parent APP is running from NOT the RoboCopy process
A lot more testing has been done today and I can confirm that setting the CurrentDirectory to the same as your source path resolves my originally submitted issue of "why when choosing the root of the same drive you are running your app from as the source results in only the content of the application startup path being copied rather than the selected source drive".
I have run multiple copies using various sources and destinations and cannot see any side effects of setting the CurrentDirectory to Source to solve this issue.
However that is not to say it will be the solution for others hence just noting it here for reference, and not raising a PR, as don't want to suggest or make a change which could impact on others use cases.
Also during this discussion another issue was discovered in the sample Backup App relating to trailing slashes which can cause problems - moved key information relating to this to a new issue #117 so it can be discussed in more detail there rather than confusing this issue.
So before running RoboCommand.Start or RoboCommand.StartAsync change the CurrentDirectory to be the same as the chosen Source directory e.g.
VB.NET
My.Computer.FileSystem.CurrentDirectory = Source
C#
System.IO.Directory.SetCurrentDirectory(Source);
Since this issue will be applicable to any application that is designed to be portable, it might make sense to create a new method that sits in the RoboSharp class that performs this operation only if needed.
Supplying a method with a good summary tag will expose the solution to those that need it in a pre-made method. Those that don’t need it simply don’t the method.
What do you think?
On Mon, Dec 6, 2021 at 5:15 PM Darren Rose @.***> wrote:
A lot more testing has been done today and I can confirm that setting the CurrentDirectory to the same as your source path resolves my originally submitted issue of "why when choosing the root of the same drive you are running your app from as the source results in only the content of the application startup path being copied rather than the selected source drive".
I have run multiple copies using various sources and destinations and cannot see any side effects of setting the CurrentDirectory to Source to solve this issue.
However that is not to say it will be the solution for others hence just noting it here for reference, and not raising a PR, as don't want to suggest or make a change which could impact on others use cases.
Also during this discussion another issue was discovered in the sample Backup App relating to trailing slashes which can cause problems - moved key information relating to this to a new issue #117 https://github.com/tjscience/RoboSharp/issues/117 so it can be discussed in more detail there rather than confusing this issue.
So before running RoboCommand.Start or RoboCommand.StartAsync change the CurrentDirectory to be the same as the chosen Source directory e.g.
VB.NET
My.Computer.FileSystem.CurrentDirectory = Source
C#
System.IO.Directory.SetCurrentDirectory(Source);
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tjscience/RoboSharp/issues/116#issuecomment-987286756, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE34HFZXUE6F3GQOHRRVIFLUPUYYPANCNFSM5JLZ2MLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
@RFBomb - yes that does make sense, just beyond my coding ability I think as I mainly use VB rather than C#, but I do get your point
EDIT: Just thinking this through further - surely the setting of CurrentDirectory would need to be done in the parent app / EXE e.g. Backup App in the case of the sample app or your own GUI that is using RoboSharp, because it is the working / current directory of the calling EXE which is relevant here, so would setting it in the DLL be relevant or even work? Just thoughts....
And now I have the question again: Why don't you want a solution without "System.IO.Directory.SetCurrentDirectory (Source);" get along? It would be better for RoboSharp to leave it to the user how he uses the CurrentDirectory. I had already presented a corresponding solution and it is also the solution that has already been proposed and recommended several times as a solution to the problem on the Internet.
And now I have the question again: Why don't you want a solution without "System.IO.Directory.SetCurrentDirectory (Source);" get along? It would be better for RoboSharp to leave it to the user how he uses the CurrentDirectory. I had already presented a corresponding solution and it is also the solution that has already been proposed and recommended several times as a solution to the problem on the Internet.
The CurrentDirectory issue I raised is COMPLETELY different to the issue you mentioned to do with trailing slashes. My app doesn't have the trailing slash issue as already explained multiple times to you which I assume is the "corresponding solution" you are referring too? Or are you referring to a different solution? if so what?
It would be better for RoboSharp to leave it to the user how he uses the CurrentDirectory.
I agree, as I said in previous response - the solution works for ME in MY app, but may not be solution for others, as problem reported was related to MY GUI written in VB which uses RoboSharp, and not the included Backup App, and I believe the other issue to do with trailing slashes is specific to that app and perhaps C# treating the \ as an escape character which VB doesn't do
So I keep talking about the problem of what happens when the root directory of the start directory is identical to Source! Which is expressed by the fact that the start directory and not the specified drive is then copied.
Yes so if source chosen is "E:" and the app is running from "E:\My_Apps\RoboSharpGUI\GUI.exe" then only the app start directory of "E:\My_Apps\RoboSharpGUI" is copied.
I KNOW this, the is whole resason I opened the issue in the first place.
This issue for me is resolved when setting the CurrentDirectory to be the same as your chosen source, as per my many replies above.
Yes, I know that your solution will run in your app. It's just not the right solution if you build them into RoboSharp.
Yes, I know that your solution will run in your app. It's just not the right solution if you build them into RoboSharp.
Which is exactly why I said what I did above when closing this issue as it would be down to the user to choose whether to implement this solution in their own apps or not, so I really don't understand why you keep coming back on the point, MY issue that I raised is resolved - conversation over.
Never noticed this before and have tried it with older RoboSharp.dll just to ensure it wasn't recent changes and it wasn't :)
If I run my app (or even the example BackupApp) from for example my E: drive (located in e:\apps\robosharp - location not really relevant) and then choose E: as my source path it only lists / copies the files / folders in the root and doesn't do sub-folders etc.
If I run it again from C:\test and choose E:\ as my source then it works perfectly fine and does all directory levels.
Thought I was going mad, so tried it on another computer and also another drive - and in all cases if you are running RoboSharp from the same drive you are choosing as your source AND you are choosing the root of that drive as your source.
Example video may illustrate it better
https://www.screencast.com/t/9DR1BqNfHgS
First attempt is app running from E: and selecting E: as source - as you can see it only finds a few files / directories and if I check log it is just seeing root and NOT doing sub-directories
Second attempt is exactly same app running from C: and selecting E: as source - now works fine and does all levels
@RFBomb or @JoE-Seeve - can you replicate this? Any thoughts?