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.
  1. To develop a NetLogic that counts files
  2. In
    Project view
    , right-click the
    NetLogic
    folder and select
    New
    Runtime NetLogic
    .
  3. Hover-over the NetLogic, select
    Edit
    , and enter
    CountFiles
    .
  4. Double-click the NetLogic.
    The external code editor opens.
  5. 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; } } }
  6. Save the code.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.