Join us today!

Notifications
Clear all

library for folder and file management, free size, rename, oldest file...

4 Posts
2 Users
2 Reactions
418 Views
runtimevictor
Posts: 156
Topic starter
(@runtimevictor)
Estimable Member
Joined: 2 years ago

 

Hello,

I am looking for a library for TwinCAT to handle folders and files, which knows the free size left on a hard drive, renames a file, knows the oldest file in case there is no space left on the hard drive, delete the oldest...
For now the libraries that I have found are the following: sysFile, Tc2_System
but they don't have everything I'm looking for...
Is there a more complete file management library or a project that manages this...
or how could i do it? If it is not possible with TwinCAT, it has also occurred to me to launch an external program that does it, but for now I want to exhaust the possibilities so that everything is centralized within the TwinCAT program...

TwinCAT Files
Reply
3 Replies
3 Replies
runtimevictor
(@runtimevictor)
Joined: 2 years ago

Estimable Member
Posts: 156

Hello,

I am looking in TwinCAT how to know the size that a directory occupies or the free space that is left on a hard disk,

what I have found for now is to use FB_EnumFindFileList and in the ST_FindFileEntry structure the file size is found with this we would have to add the size of all the files found...

It is not valid because many PLC cycles are needed for it to give us all the files that are in a directory and thus be able to calculate the size that all the files occupy within a directory...

Is there an easier way to get it from TwinCAT?...

EnumList
Reply
runtimevictor
(@runtimevictor)
Joined: 2 years ago

Estimable Member
Posts: 156

Hello,

I have found Beckhoff Device Manager, 0x8nn6 – Free space (Bytes) but I don't know how to access it through TwinCAT...

Beckhoff Device Manager

searching i found this video, 

- [Webinar Przy Kawie 16: Czy Twój sterownik ma gorączkę? Diagnostyka IPC krok po kroku.]

https://www.youtube.com/watch?v=PY0L7lu-wDc

but I have realized that the MDP thing is not worth it either, since the hard disk is going to be a NAS server with linux 😭 

Reply
benhar-dev
(@benhar-dev)
Joined: 2 years ago

Eminent Member
Posts: 17

Hi @runtimevictor, this project comes with a word of warning.  Just because we can do something doesn't mean we should 🙂

NT_StartProcess is one of my favourite things to exploit.  I often try to condense a whole PowerShell, ads router, program all in to the 510 character limit of this function block.

https://github.com/benhar-dev/tc3-drive-free-space

If you are interested in how I make this type of code, then also see this repo.

https://github.com/benhar-dev/ps-to-ntstartprocess

Reply
Share: