Write txt file to controler
Hi.
string sDir = ctrl.FileSystem.LocalDirectory;
// Check if the file exists
I'm using RW5.10 and RAB 5.10
I'm trying to create, write to and read from a txt file on the controller.
I become no error from my code but nothing is written on the controller (hd0a/Temp).
The code works in virtual controler but not in a real controler.
I have attached my code below from my real controler.
Does someone know what I'm doing wrong?
string sDir = ctrl.FileSystem.LocalDirectory;
String sFileName = sDir + "/RabApplication2.txt";
DateTime dDate = DateTime.Now;
// Check if the file exists
if (!System.IO.File.Exists(sFileName))
{
// Sparar datum i filen fA?r att kontrollera antal dagar frA?n
System.IO.StreamWriter sw = new System.IO.StreamWriter(sFileName);
sw.WriteLine(crypto.EncryptString(dDate.ToString(), sCryptoKey));
sw.WriteLine(crypto.EncryptString("Not licensed", sCryptoKey));
sw.Close();
}
Best regards M Johnson
M Johnson2009-01-23 07:51:09 0
Comments
-
You are going about it the right way, but the .Net functionality doesn't know anything about the robot file system. Local directory by default is actually the directory "/temp" on the FlexPendants's RAMdisk.So, what you are doing is creating the file on the flexpendant. That is what you have to do, but when you are finished you need to call FileSystem.PutFile to copy the file from the local directory (FP) to the remote directory (by default, the HOME directory of the active system).Also, you may find that "Now" doesn't give you an accurate time, you might want to use the controller's date and time.RussD2009-01-23 15:11:33Russell Drown0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 799 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings