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