Accessing files by index

Results 1 to 2 of 2

Thread: Accessing files by index

  1. #1
    Einar Guest

    Default Accessing files by index

    I&#039m having trouble accessing a single file in a folder&#039s files collection, without knowing the actual name of the file. That is, I would like to be able to use some code like this<BR>Set myFolder = fs.GetFolder(Server.MapPath("/someFolder/"))<BR>Set myFile = myFolder.Files(1)<BR>to access the first file in the collection.<BR>My "ASP in a Nutshell" claims that this is possible, but I get an error saying<BR>"Microsoft VBScript runtime error &#039 800a0005&#039, Invalid procedure call or argument"<BR><BR>Can anyone help? I&#039m quite new at this :)<BR><BR>

  2. #2
    Einar Guest

    Default RE: Accessing files by index

    Update:<BR>It seems that the Files-collection refuses to take a variable as parameter, is this true?<BR>(i.e. this snippet of code works fine:<BR>&#060;% Set myFile = myFolder.Files("1.txt") %&#062;<BR>whereas this doesn&#039t:<BR>&#060;%<BR>Dim myFileName<BR>myFileName = "1.txt"<BR>Set myFile = myFolder.Files(myFileName)<BR>%&#062;<BR>How come? Any thoughts appreciated! :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts