Can I use FileSystemObject get a single file from a folder using its index?
<p>If there is only one file in a folder, can I pick it up <strong>without</strong> knowing its name or iterating through the files in the folder?</p>

<p>(The code is VBS, but it could be anything, the FSO is the interesting part here.)</p>

<p>This didn't work for me:</p>

<pre><code>dim fso
set fso = CreateObject("Scripting.FileSystemObject")
dim myFolder
Set myFolder = fso.getFolder("E:\test")
Dim myfiles
Set myfiles = myFolder.Files

WScript.Echo myfiles.Item(0).Path
</code></pre>

<p>Neither did <code>WScript.Echo myfiles(0).Path</code> work. (Index 0,1 tested, both fail.)</p>

<p>Using a for each to get just one file seems a bit of an overkill. Also, am I not supposed to be able to somehow iterate with a simple <code>For</code> loop, not a <code>For Each</code>? So there must be indexes... I just can't seem to find them.</p>