ADODB.Stream LoadFromFile -> File could not be opened.

kwebster7327
kwebster7327 used Ask the Experts™
on
I'm using the ADODB.Stream LoadFromFile method to grab a binary file so that I can download it in my classic ASP page.

For whatever reason, it's throwing a "File could not be opened." error and I can't see why.

Just to eliminate the permissions aspect, I have modifified the code and proven I **CAN** open the same file for reading with the FileSystemObject. Since it's binary, the FSO's output is useless, though.

Can anybody see what I'm doing wrong (ErrHandle is my generic error handler)?

        Set objStream = Server.CreateObject("ADODB.Stream")
        if err.number <> 0 then
            ErrHandle 1, Err.Description
        end if
       
        objStream.Type = 1  ' adTypeBinary
        if err.number <> 0 then
            ErrHandle 2, Err.Description
        end if
       
        call objStream.Open()
        if err.number <> 0 then
            ErrHandle 3, Err.Description
        end if
       
        objStream.LoadFromFile strFilePath  ' <==== this fails! file CAN be opened through FSO
        if err.number <> 0 then
            ErrHandle 4, Err.Description & "<br>Number: " & cstr(err.number) & "<br>File: " & txtFile
        end if


Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Expert of the Year 2008
Top Expert 2008
Commented:
>>ErrHandle 4, Err.Description & "<br>Number: " & cstr(err.number) & "<br>File: " & txtFile
OK, so do you have the FULL path to the file in
strFilePath or in txtFile?

If you only have the file name, try providing the FULL path - C:\folder\yourfile.jpg
Expert of the Year 2008
Top Expert 2008

Commented:
Also, try specifying the Type AFTER you call open

Author

Commented:
Just needed another pair of eyes. strFilePath != txtFile.

BTW, moving TYPE doesn't have an effect.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial