kwebster7327
asked on
ADODB.Stream LoadFromFile -> File could not be opened.
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
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, try specifying the Type AFTER you call open
ASKER
Just needed another pair of eyes. strFilePath != txtFile.
BTW, moving TYPE doesn't have an effect.
BTW, moving TYPE doesn't have an effect.