tags:

views:

310

answers:

1

My code is pulling from a data cells that lists multiple file paths and use semicolons " ; " as the separator. After spliting the data and placing it into an array, I need to remove the semicolons. otherwise my file paths are invalid when they enter the loop.

To clarify: My code works when there is only one file path in the data cell and dies once it hits a cell with multiple paths because of the ";"

ANY HELP would be much appreciated.

My code is the following:

<%
strValue = RS("ATTACHMENTS")
strAryWords = Split(strValue, ";")

' - strAryWords is now an array
For i = 0 to Ubound(strAryWords)
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    Set fileObject = fso.getFile(strAryWords(i))

    Response.Write "<TH><TR align=left><TD>" & strAryWords(i) &"  "& fileObject.Size &"  "&"<img src=images/up.gif><BR></TD></TR>"

    Set fileObject = Nothing
    Set fso = Nothing  
Next
%>
A: 

If the problem is strValue has a trailing ';', change your code to this:

strValue = RS("ATTACHMENTS")
strAryWords = Split(strValue, ";")


' - strAryWords is now an array
For i = 0 to Ubound(strAryWords)
    If strAryWords(i) <> "" Then
        Set fso = Server.CreateObject("Scripting.FileSystemObject")
        Set fileObject = fso.getFile(strAryWords(i))

        Response.Write "<TH><TR align=left><TD>" & strAryWords(i) &"  "& fileObject.Size &"  "&"<img src=images/up.gif><BR></TD></TR>"

        Set fileObject = Nothing
        Set fso = Nothing
    End If
NEXT
Patrick Cuff
YEAH!! This worked like a charm..thanks you much