Backup PC SDK Problem

I am trying to use the Backup call on a 5.12 RAB PC SDK application with a controller running 5.11.3 when I execute the code below after getting mastership of the controller I get the exception "Unable to create directory"  If I use the same code on the Virtual controller running on the same PC as my application it works fine.  Anybody have any Ideals why that is.

    Dim BackupDir As String = ""
    BackupDir = "ctrl:C:/Backup"
        Catch ex As GenericControllerException
          MessageBox.Show(ex.Message.ToString, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try

Newbe2009-10-14 07:46:57


  • Hi ,
    File System on Real Controller is not same as on PC( Windows)

    You need to mention the Backup directory name. e.g "MyBackup"


    now use this

    Saleem Javed

  • Thank you for the response but that just creates the backup on the controller in the BACKUP folder.  I want the backup to be created on my PC running my PC SDK application.  so I have a folder on the root of my PC's hard drive called BACKUP and I want to create my backup of the controller in that folder so I would think the code should be:

    BackupDir = "ctrl:c:/BACKUP/NewBackup"

    which would cause the folder NewBackup to be created in the folder BACKUP and all the controllers backup information would go in that folder?  right?

    Newbe2009-10-14 07:47:10
  • When you create a backup on the real controller using the Controller.Backup(path) function, it stores the backup in the folder you gave as location relative to the Controller.FileSystem.RemoteDirectory folder.


    Example: (Say that the RemoteDirectory is set to the HOME folder on the controller)


    This will create a backup and stores it on the controller in the HOME/TestBackup folder.


    What you could do is:

    1) Create a backup on the controller using Controller.Backup(string path)

    2) Wait until backup is completed using Controller.BackupInProgress property

    3) Send the folder with backup to the desired location on your PC using Controller.FileSystem.GetDirectory(string remoteDirectory, string localDirectory).

    4) If necessary you can delete the backup from the controller using Controller.FileSystem.RemoveDirectory(string path)
  • thank you for the response...can you give a example of what the string for remoteDirectory and LocalDirectory would look like please?

  • Ok lets say we want to create a backup from the controller on our computer at C:Temp in a folder named BACKUP.


    1) Create a backup at the real controller using the Controller.Backup(string path) function:

    The RemoteDirectory property of Controller.FileSystem is set to the HOME folder of the controller ( "/hd0a/14M-51688/HOME" ) were 14M-51688 is the name of my controller. And the path you give to the Backup function is relative to the RemoteDirectory property, so:



    while (Controller.BackupInProgress) { }


    This will create the backup in the following folder "/hd0a/14M-51688/HOME/TestBackup".


    2) Copy the folder containing the backup from controller to computer:

    The remote directory is again relative to the RemoteDirectory so you can give the same folder as you gave to the Backup function.


    Controller.FileSystem.GetDirectory("TestBackup", "C:\Temp\BACKUP")


    This will copy the backup from the controller to the computer at C:TempBACKUP.


    You should add some checks to check if directories exist and else you should create them.
  • Thanks KSP I will give that a try today and post back my results image
  • Hello KSP,

    Wanted to let you know that the backup on the controller and then using
    the GetDirectory works fine.  The problem is that the RemoveDirectory
    does not work.

    Here is the code for the button_click:

    Dim BackupDir As String = "MyBackup"


    Here is the code for the BackupCompleted Event:

    Dim BackupDir As String = "MyBackup"


    below is the error that I get.  I do have Mastership of the controller.  Any help that you or anybody else could offer would be great.


  • Ok...I figured it I needed to set the RemoteDirectory to the full path before I made the call to RemoveDirectory

    controller.FileSystem.RemoteDirectory() = "/hd0a/66-59720/HOME"
    controller.FileSystem.RemoveDirectory(BackupDir, True)

    This works fine on a real controller...image

  • scottdf93
    scottdf93 United Kingdom

    I am attempting to do the same thing but when ever i try and use the GetDirectory function I throws the exception;

    {"Operation is not valid due to the current state of the object."}

    Any idea what is causing this? Both remote and local directories are set correctly.
  • daniel72
    daniel72 Germany
    edited May 2021
    I am also have this problem:
    when ever i try and use the GetDirectory function I throws the exception;

    {"Operation is not valid due to the current state of the object."}

    Any idea what is causing this? The Sourcepath is on an virtual maschine in my case.

  • Nils Olofsson
    Nils Olofsson Sweden admin
    Maybe if you share a snippet of you code we can provide some assistance. 

    Nils Olofsson
    PC Software Support Engineer

  • daniel72
    daniel72 Germany
    edited June 2021
    Hi Nils

    I'm trying to copy directory BACKUP from C:/Users/danie/Documents/RobotStudio/Virtual Controllers/AE_Rob1_V06/HOME/BACKUP_230621"
    to local directoy D:/Temp/BACKUP";

    //string sbackupDir = "(BACKUP)$" + aController.SystemName + "_" + sDatum;
    string sbackupDir ="BACKUP_" + sDatum;
    string sBackupDirPath= @C:/Users/danie/Documents/RobotStudio/Virtual Controllers/AE_Rob1_V06/HOME/BACKUP_230621;
    string sPCStoreDir = @D:/Temp/BACKUP;
    string sRemotebackupDir = aController.FileSystem.RemoteDirectory + "/" + sbackupDir;

    Console.WriteLine("st_RobotDirectoryPath {0}", aController.FileSystem.RemoteDirectory);  // is set to HOME-Dir in system dir
    Console.WriteLine("sRemotebackupDir {0}", sRemotebackupDir);

    aController.FileSystem.LocalDirectory = sPCStoreDir;

    //aController.FileSystem.PutFile("test.txt");  //this works. put the file from D:/Temp/BACKUP  into HOME-Dir of Robot

    //aController.FileSystem.GetFile("test2.txt");  //this works. get  file from HOME-Dir into  D:/Temp/BACKUP
    //This will copy the backup from the controller to the computer at D:/Temp/BACKUP
    aController.FileSystem.GetDirectory(sBackupDirPath, sPCStoreDir,true);   //Exeption: "Directory is not empty"
    aController.FileSystem.GetDirectory(sBackupDirPath, sPCStoreDir,false);  //Exeption: "Operation is not valid due to the current state of the object
    aController.FileSystem.GetDirectory(sBackupDir, sPCStoreDir,false);      //Exeption: "Operation is not valid due to the current state of the object

    Which path specifications does GetDirectory expect - Absolute or relative to FileSystem.RemoteDirectory?
    I've tried both variants
    I read in another post that you should set FileSystem.RemoteDirectory again before GetDirectory. But what, is it still on HOME? 

    Thank you!


  • Nils Olofsson
    Nils Olofsson Sweden admin

    it seems as the Boolean argument wont succeed with the overwrite of the existing directory. Let me get back to you on that. 

    If you make sure that the directory does not already exist on the PC, does it work then?

    Nils Olofsson
    PC Software Support Engineer