PC SDK "GetDirectory" problem

Hi All,

Basic concept is to creat a backup on the flexpendent controller and the copy that directory to the local HDD of the PC that is running the SDK but I keep having a problem getting the “CopyDirectory” or “GetDirectory” methods to work!

My Code:
//string st_BackUp = this.controller.SystemName;
string st_BackUp = this.controller.SystemName + “_TEST”;
string st_RobotDirectoryPathCk = (“”);
string st_folderName = “C:\TEMP_NS”;
string st_RobotDirectoryPath = “”;
string st_LocalBackupPath = Path.Combine(st_folderName, st_BackUp);

//Create string for comparision between path name methods
st_RobotDirectoryPathCk = this.controller.FileSystem.RemoteDirectory;

// Create second controller directory path string using different method
st_RobotDirectoryPath = controller.GetEnvironmentVariable(“HOME”) + @“/”;

string st_RobotBackupPath = (st_RobotDirectoryPath + “/” + st_BackUp);

// Display path
MessageBox.Show("current Robot Directory is set to: " + st_RobotDirectoryPath);

MessageBox.Show("current Robot Directory check is set to: " + st_RobotDirectoryPathCk);

//Create backup in HOME or BACKUP directory with system name.
this.controller.Backup(st_BackUp);
while (this.controller.BackupInProgress)
{
MessageBox.Show(“Backup In progress”);
}

MessageBox.Show(“Backup complete”);

// Create directory on local system and copy backup to that location.
Directory.CreateDirectory(st_LocalBackupPath);
this.controller.FileSystem.GetDirectory(st_RobotBackupPath, st_LocalBackupPath);

I Have tried writing the file paths but stll have the same problem.

error message when running “GetDirectory”: “Operation is not valid due to the current state of the object”

Any help appreciated,

Running RS 5.15.02 VS 2010 express

Hi,

Had the exact problem with the FileSystem. The code below started to work…

‘’’


‘’’ Creates a backup on the robot, copies the backup to PC and removes the backup vrom the robot.
‘’’

‘’’ Dir to be created in the /hd0a/BACKUP/ folder at he robot
‘’’ Directory at local PC to where the backup is being copied
‘’’ True or false
‘’’
Public Function GetBackup(ByVal dirAtRobot As String, ByVal dirAtPC As String) As Boolean
Try
’ Login
_selController.Logon(UserInfo.DefaultUser)
’ Create backup
_selController.Backup(“(BACKUP)$” & “/” & dirAtRobot)

’ Wait for the backup to finish
While _selController.BackupInProgress
Threading.Thread.Sleep(50)
Application.DoEvents()
End While

’ Create dir on local PC, if doesn’t exist
If Not IO.Directory.Exists(dirAtPC) Then
IO.Directory.CreateDirectory(dirAtPC)
End If

’ IMPORTANT! Set the RemoteDirectory!!!
_selController.FileSystem.RemoteDirectory = “(BACKUP)$”
’ Just get the directory from the remote dir
_selController.FileSystem.GetDirectory(dirAtRobot, dirAtPC, True)
’ Remote the directory on the robot
_selController.FileSystem.RemoveDirectory(dirAtRobot, True)

Return True
Catch ex As Exception
Throw ex
Finally
’ Own stuff…
LogOffController()
End Try
End Function

Hope this helps!