Solved

FSO object and spaces in file names

Posted on 2004-08-19
5
302 Views
Last Modified: 2006-11-17
Good Morning all!!

I am using the FSO object to read in files that are included in a folder and then turning around and spitting them out as hyper links.

Once the user clicks on the links I am passing the file name in the query string as I reload the page for the next step in processing.

Here is the problem.  If I have spaces in the file name (as most of our docs do) then when I read in the file the name is being truncated at the first space.  I have searched the web and EE for a resolution and other then re-writing my code to use the GetFile method rather then the GetFolder method I am not sure how to read in the files in the folder that have spaces in them.

Here is a snippet of my code:

Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(fileloc)
Set files = folder.Files
i=0
For Each file in files
                  redim preserve dir2(i)
                  dir2(i)= file.name
                  redim preserve dir3(i)
                  dir3(i)= file.datelastmodified
                  redim preserve dir4(i)
                  dir4(i)= file.size
                     i = i + 1
            Next

As an aside... I know I could use a multi dimensional array rather then 3 different ones but I added them in at different times and this was easier :-/
0
Comment
Question by:lharrispv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 15

Expert Comment

by:Colosseo
ID: 11841951
Hi

If you are passing the filename in the querystring you could try replacing the spaces with %20

so in your code instead of

dir2(i)= file.name

 try

dir2(i)= replace(file.name," ","%20")

Then when you read the file name from the querystring you could pass it back through to change the %20 back in to a space. so something like

filename = replace(request.querystring("filename"),"%20"," ")

Another way to do this without the querystring might be to store the file name in a hidden tag on the form. Then when you submit the form you could use Request.Form("[filename field]")

HTH

Scott
0
 
LVL 8

Author Comment

by:lharrispv
ID: 11842043
Thanx for the response!!

The problem is that by the time the name gets into the query string it is already truncated.  This is happening when I first read the file name in with FSO object.
0
 
LVL 15

Expert Comment

by:Colosseo
ID: 11842074
Hi

so in your for loop if you add a response.write

                redim preserve dir2(i)
               dir2(i)= file.name
               response.write file.name

then the output file.name is already truncated at the first space there?

Scott
0
 
LVL 19

Accepted Solution

by:
peh803 earned 250 total points
ID: 11842084
try executing server.urlencode() around the querystring value before you pass it into the querystring...this should help...

regards,
peh803
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11842441
What do you get when you do this--are the names truncated here:

for i=0 to UBound(dir2)
   Response.write(dir2(i) & "<BR>")
next

FtB
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Session on Html 8 53
Display field if column exists 7 56
Making Table Thru ASP Response.write 5 35
Help with IIS intermittent hangs on Windows 2012 5 56
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question