Develop a NetLogic that counts files
This C# NetLogic calculates the number of files in the project folder and returns the result in the output parameter.
Prerequisites
Set the default external code editor. See Set the default code editor.
- To develop a NetLogic that counts files
- InProject view, right-click theNetLogicfolder and select .
- Hover-over the NetLogic, select , and enterCountFiles.
- Double-click the NetLogic.The external code editor opens.
- In the code editor, replace the existing code with the following code:#region Using directives using System.IO; using FTOptix.HMIProject; using FTOptix.NetLogic; #endregionpublic class CountFiles : BaseNetLogic { [ExportMethod] public void RuntimeScript1Method(out int filesCount) { var projecfilestpath = Project.Current.ProjectDirectory; filesCount = 0; DirectoryInfo d = new DirectoryInfo(projecfilestpath); FileInfo[] Files = d.GetFiles("*.*"); foreach (FileInfo file in Files) { ++filesCount; } } }
- Save the code.
Provide Feedback