Description
The FileNameByIndex
method lets you obtain the full path to the file that is stored in the Files
, Objects
or Regions
collection as an item having the specified index.
Declaration
ProgObj.FileNameByIndex(Index)
ProgObj | An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section | |||
Index | [in] | Required | Integer | |
Result | String |
Applies To
The method is applied to the following objects:
Parameters
The method has the following parameter:
Index
Zero-based index of the collection's item that refers to the file whose path you want to get. To learn the total number of items in the collection, use Count
.
Result Value
The full path to the file referred to by an item with the specified index in the collection.
Example
The following example demonstrates how you can get the names of items of the Files collection and the names of the corresponding stored files.
JavaScript, JScript
{
var i;
// Posts the names of the items stored in the Files collection
Log.Message(Files.NamesList());
// Posts the names of the files stored in the Files collection
Log.Message(Files.FileNamesList());
// Posts the total number of items stored in the Files collection
Log.Message("The total number of files: " + Files.Count);
// Iterates through the items of the collection and posts their names and the names of the corresponding files to the log
for (i = 0; i < Files.Count; i++)
Log.Message(Files.NameByIndex(i) + " stores " + Files.FileNameByIndex(i));
}
Python
def Test1():
# Posts the names of the items stored in the Files collection
Log.Message(Files.NamesList())
# Posts the names of the files stored in the Files collection
Log.Message(Files.FileNamesList())
# Posts the total number of items stored in the Files collection
Log.Message("The total number of files: " + str(Files.Count))
# Iterates through the items of the collection and posts their names and the names of the corresponding files to the log
for i in range(i, Count):
Log.Message(Files.NameByIndex[i] + " stores " + Files.FileNameByIndex[i])
VBScript
' Posts the names of the items stored in the Files collection
Log.Message(Files.NamesList())
' Posts the names of the files stored in the Files collection
Log.Message(Files.FileNamesList())
' Posts the total number of items stored in the Files collection
Log.Message("The total number of files: " & Files.Count)
' Iterates through the items of the collection and posts their names and the names of the corresponding files to the log
For i = 0 To Files.Count-1
Log.Message(Files.NameByIndex(i) & " stores " & Files.FileNameByIndex(i))
Next
End Sub
DelphiScript
var
i : OleVariant;
begin
// Posts the names of the items stored in the Files collection
Log.Message(Files.NamesList());
// Posts the names of the files stored in the Files collection
Log.Message(Files.FileNamesList());
// Posts the total number of items stored in the Files collection
Log.Message('The total number of files: ' + Files.Count);
// Iterates through the items of the collection and posts their names and the names of the corresponding files to the log
for i := 0 to Files.Count-1 do
Log.Message(Files.NameByIndex(i) + ' stores ' + Files.FileNameByIndex(i));
end;
C++Script, C#Script
function Test1()
{
var i;
// Posts the names of the items stored in the Files collection
Log["Message"](Files["NamesList"]());
// Posts the names of the files stored in the Files collection
Log["Message"](Files["FileNamesList"]());
// Posts the total number of items stored in the Files collection
Log["Message"]("The total number of files: " + Files["Count"]);
// Iterates through the items of the collection and posts their names and the names of the corresponding files to the log
for (i = 0; i < Files["Count"]; i++)
Log["Message"](Files["NameByIndex"](i) + " stores " + Files["FileNameByIndex"](i));
}
See Also
Count Method
NameByIndex Method
FileNameByName Method
NameByFileName Method
FileNamesList Method