Creating Folders with eCLR: Forbidden
I am trying to develop an application using the eCLR library with C#. I program various logic blocks that are then used by a PLC.
I see from the help file that the System.IO classes Directory and DirectoryInfo are not supported. This is a major problem for us since the application involves creating, reading, moving, and deleting numerous files.
Is there any possible workaround or any assistance whatsoever for somehow gaining the ability to create folders? I don't need to delete them or rename them, only create. I already tried creating my own class and then referencing it in eCLR, that didn't work. Please help!
Thanks very much,
Alex Hearn
Armstrong Fluid Technology
Toronto, Canada
Comments
Hi Alex,
One work-around might be as follows:
touch /opt/plcnext/myfile
)PlcnextBaseServices
andPlcnextBase
.ServiceProvider
program.PBCL_FileCopy_1
function block./opt/plcnext/mynewdir
).The new directory will be created with the dummy file in it, but this is the only way I could get this FB to work without error.
Perhaps someone else has a better idea.
You could also contact the developer of the PlcnextBase library (via the Store) and put in a feature request for a "Create Directory" function.
Hope this helps.
~ Martin.
Hi Martin,
I work with Alex Hearn.
Thanks for your answer, we tested the PLCNextBase Library and it worked! We were able to create a directory.
However, we have one more question: The PBCL_FileCopy FB takes as destination path (input strDstPath) a string of type PBCL_STR_500, but my C# FB can't output this type of string. I believe C# only has IecString80.
Can you please clarify?
Thanks,
Alex
Hi Alex,
Glad to hear you have something working.
You are correct, the IEC type "String" has a maximum length of 80 characters. However it is possible to define your own String data types with different maximum lengths (this is described in the PLCnext Help system).
The PLCnextBase library has defined it own custom String datatype, called
PBCL_STR_500
with (I am guessing from the name) a maximum length of 500 characters. You can declare a variable of this data type in your own IEC-61131 POU, and then assign the value of your C# string to that variable before passing it to the PBCL_FileCopy FB.Hope this helps.
~ Martin.
Thanks Martin,
Using the PBCL_FileCopy FB achieved the goal.
Regards,
Alex