File.FindFilesWithExt
Skip to content
mnscript
string[] File.FindFilesWithExt(string, string) 

Description ​

Returns an array of files in the given directory with a certain extension.

Arguments ​

string - The directory to search.
string - The extension to filter.

Returns ​

string[] - An array of files found in the directory.

Example ​

msc
using File;
using Console;
using Array;
using Util;

// Finds the .txt files in "r/documents" and prints them to console.

string[] files = File.FindFiles("r/documents", "txt");
number numFiles = Array.Length(files);
number fileIndex = 1;

Console.WriteLine("Found "..Util.ToString(numFiles).." files!");

while(fileIndex <= numFiles){
    Console.WriteLine("File: "..files[fileIndex]);
    fileIndex = fileIndex + 1;
}