# PC SDK "GetDirectory" problem

**URL:** <https://tech-community.robotics.abb.com/t/pc-sdk-getdirectory-problem/5821>\
**Category:** Developer Tools\
**Created:** [November 19, 2013, 3:32pm UTC](https://tech-community.robotics.abb.com/t/pc-sdk-getdirectory-problem/5821 "2013-11-19T15:32:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterG](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@PeterG](https://tech-community.robotics.abb.com/u/PeterG)\
**Post date:** [November 19, 2013, 3:32pm UTC](https://tech-community.robotics.abb.com/t/pc-sdk-getdirectory-problem/5821/1 "2013-11-19T15:32:37Z")

</div>

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, VS2010 C# Express.
