Sometimes it is required to have list of files from some folder. Here we demonstrate how to get this list and how to iterate through it in RVL.

We need to use JavaScript to get list of file names. Go to the Functions file for the test:

 

And add GetFolderFiles function as follows:

 

/**
 * Return an array with all files from specified folder
 */
function GetFolderFiles(/**string*/folderPath)
{
	var folder = File.FolderInfo(folderPath);
	var files = folder.Files;
	
	var fileList = [];
	
	var e = new Enumerator(folder.Files);
	for (;!e.atEnd();e.moveNext()) {      // Loop over the files in a folder
		var file = e.item();
		fileList.push(file.Name);
	}
	return fileList;
}

Now it is possible to get array of files in a given folder like that:

And, if needed, go through the array in the loop:

An attached test case iterates through the list of files in the C:\Temp folder.

FldTry.zip

 

 

 

 

 

 

Attachments

Selected files will be attached to any email sent on saving ticket.

file selected files selected  () Delete Selected

  • Created:
  • by:

Select files to upload

Or drag and drop files here

Uploading …
Done!
Upload More?
There was an error.
Try again?

Save to upload the selected file(s)

Article Info
  • Last Updated: 2/8/2018
  • Article ID: KB324
  • Views: 56