RobotStudio event

PCSDK GetDirectory not working on Omnicore Controller

edited September 26 in OmniCore
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):

//Create temporary directory on controller
if (c.FileSystem.DirectoryExists(tempPath)) 
    c.FileSystem.RemoveDirectory(tempPath, true);
//load backup into temp Directory
//Wait until Backup finished
try { while (c.BackupInProgress) { Thread.Sleep(100); } }
catch(Exception e)
        statusLabels![i].BackColor = Color.Red;
        statusLabels[i].Text = e.ToString();
//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?

Post edited by knotext on

Best Answer

  • Tompanhuhu
    Tompanhuhu ✭✭
    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
                    c.FileSystem.RemoteDirectory = "";
                    return c.GetEnvironmentVariable("TEMP")+"/TempBackup";
            c.FileSystem.GetDirectory(remoteBackupDir, systemBackupDir, true);

    Systemintegrator - Web / C# / Rapid / Robotstudio

    If I helped, please press Vote Up  :smile: