Jump to content

Read Multiple Files


shaman

Recommended Posts

I'm trying to open 3 files all at once currently.... I use this codeSet fs=Server.CreateObject("Scripting.FileSystemObject")Set fso=Server.CreateObject("Scripting.FileSystemObject")Set fsoa=Server.CreateObject("Scripting.FileSystemObject")set a=fs.openTextFile(Server.MapPath("file1"))set b=fso.openTextFile(Server.MapPath("file2"))set c=fsoa.openTextFile(Server.MapPath("file3"))But this does not have the desired effect as it just does this:this is the result of file 1's code:content of file 1this is the result of file 2's code:content of file 1content of file 2this is the result of file 3's code:content of file 1content of file 2content of file 3So it adds on the file I open to the end of the content of the files that were opened before it.How do I open them all for reading properly?JAD

Link to comment
Share on other sites

You only need 1 filesystem object, but it shouldn't do what you're describing. You can use mode 1 to open the files for reading.Set fs=Server.CreateObject("Scripting.FileSystemObject")set a=fs.openTextFile(Server.MapPath("file1"), 1)set b=fs.openTextFile(Server.MapPath("file2"), 1)set c=fs.openTextFile(Server.MapPath("file3"), 1)Response.Write("file 1: " & a.ReadAll() & "<br><br>")Response.Write("file 2: " & b.ReadAll() & "<br><br>")Response.Write("file 3: " & c.ReadAll() & "<br><br>")

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...