PCSDK GetDirectory not working on Omnicore Controller
Hello all,
I have written a program with Windows Forms and C# to create Backups from all connected controllers on the Network. The tool works great with IRC5-Controllers, but when there's an Omnicore-Controller, I get an Error-Message during copying a temp-File from the Controller to the local Machine.
How do I create a Backup:
1. Create a temporary Directory for the Backup on the Controller (maybe unneccessary?)
2. Create the Backup into this directory
3. Copy the directory from the controller to the local machine (I use the function GetDirectory)
4. Remove the directory and all files in it from the controller (I just want the Backup to be on my Computer)
My temporary path looks like this:
tempPath = "Backup_in_progress";
And the Backup-Steps are the following (Mastership is granted):
[...]
I have written a program with Windows Forms and C# to create Backups from all connected controllers on the Network. The tool works great with IRC5-Controllers, but when there's an Omnicore-Controller, I get an Error-Message during copying a temp-File from the Controller to the local Machine.
How do I create a Backup:
1. Create a temporary Directory for the Backup on the Controller (maybe unneccessary?)
2. Create the Backup into this directory
3. Copy the directory from the controller to the local machine (I use the function GetDirectory)
4. Remove the directory and all files in it from the controller (I just want the Backup to be on my Computer)
My temporary path looks like this:
tempPath = "Backup_in_progress";
And the Backup-Steps are the following (Mastership is granted):
[...]
//Create temporary directory on controller
if (c.FileSystem.DirectoryExists(tempPath))
{
c.FileSystem.RemoveDirectory(tempPath, true);
c.FileSystem.CreateDirectory(tempPath);
}
//load backup into temp Directory
c.Backup(tempPath);
//Wait until Backup finished
try { while (c.BackupInProgress) { Thread.Sleep(100); } }
catch(Exception e)
{
Invoke((MethodInvoker)delegate
{
statusLabels![i].BackColor = Color.Red;
statusLabels[i].Text = e.ToString();
});
c.Logoff();
continue;
}
//Copy temporary Directory to local Computer...
c.FileSystem.GetDirectory(tempPath, path, true); <-- At this point I get the Error
//...and remove it from the controller
c.FileSystem.RemoveDirectory(tempPath, true);
[...]
The Error-Message is the following:
System.IO.DirectoryNotFoundException: "ctrl:C:/Users/obs/Documents/RobotStudio/Virtual Controllers/P2064_R03/HOME/Backup_in_progress"
I tried to add the "ctrl:" before my tempPath, but this wouldn't work. Also I tried to use this as tempPath: "(BACKUP)$/backup_in_progress", but this didn't work either.
And just as reminder: On IRC5 it worked perfectly (RC and VC).
Edit: I tried further and I found, that the GetDirectory-function tries to open directories from the HOME-Folder on the Controller. How can I open Directories from the root directory, where the BACKUP-Folder sits?
[...]
The Error-Message is the following:
System.IO.DirectoryNotFoundException: "ctrl:C:/Users/obs/Documents/RobotStudio/Virtual Controllers/P2064_R03/HOME/Backup_in_progress"
I tried to add the "ctrl:" before my tempPath, but this wouldn't work. Also I tried to use this as tempPath: "(BACKUP)$/backup_in_progress", but this didn't work either.
And just as reminder: On IRC5 it worked perfectly (RC and VC).
Edit: I tried further and I found, that the GetDirectory-function tries to open directories from the HOME-Folder on the Controller. How can I open Directories from the root directory, where the BACKUP-Folder sits?
Post edited by knotext on
Tagged:
0
Best Answer
-
Here is my code used with my github addin.
It works for both RW6 and RW7, both virtual och real controllers.public Controller c = null; public string remoteBackupDir { get { c.FileSystem.RemoteDirectory = ""; return c.GetEnvironmentVariable("TEMP")+"/TempBackup"; } } // c.Backup(remoteBackupDir); // c.FileSystem.GetDirectory(remoteBackupDir, systemBackupDir, true);
Systemintegrator - Web / C# / Rapid / Robotstudio
If I helped, please press Vote Up
☑️2024 - RobotStudio® User Group1
Answers
-
Thank you very much, this solved the issue!0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 798 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings