PCSDK - File handling
fabian
✭
Hi all,
I have the following problem, when I try to find out, if a file or directory exists within my C# project (in a virtual and also in a real system):
"ArgumentException: Parameter name: path2"
ControllerFileSystemInfo[] sInfo = controllerFS.GetFilesAndDirectories("*");
Console.WriteLine(sInfo[0].Name); // this is OK (e.g. "Windows" in the virtual system)
Console.WriteLine(sInfo[0].FullName); // this is OK ("ctrl:C:/Windows")
if (sInfo[0].Exists) Console.WriteLine("Success"); // ArgumentException
The same happens with DirectoryExists and FileExists with the FullName as path.
What is the best method to find out, if the respective ControllerFileSystemInfo entry relates to a file or directory? The help mentiones a enum FileType, but it seems to be used nowhere?
Thanks very much for your help!
Fabian
Tested with Robotstudio 5.13.03, Win 7 32 and 64bit, VS 2008 and 2010 getting the same error.
fabian2011-02-16 00:22:45
-------------------------
Robotstudio 5.13.03
Robotstudio 5.13.03
0
Comments
-
HiDirectoryExists and FileExists are not working if the complete path is used. You have to use code according to the example below as a workaround.string homePath = controller.GetEnvironmentVariable("HOME") + @/;
string temp = "PickMaster";
controller.FileSystem.RemoteDirectory = homePath;
if (!controller.FileSystem.DirectoryExists(temp))
{
controller.FileSystem.CreateDirectory(temp);
}The sInfo[0].Exists malfunction is probably a bug that needs to be fixed. We will investigate this.Lennart H0 -
Hi Lennart,
thanks very much, this helps.
Another "workaround " to see, if a entry is a directory, file or device is
ControllerFileSystemInfo[] sInfos = controllerFS.GetFilesAndDirectories("*");
if (sInfos[0].GetType() == typeof(StorageDeviceInfo)) { // Device }
else if (sInfos[0].GetType() == typeof(ControllerFileInfo)) { // File }
else if (sInfos[0].GetType() == typeof(ControllerDirectoryInfo)) { // Directory }
and then cast it to the respective type.
Best regards
Fabian
-------------------------
Robotstudio 5.13.030
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 786 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings