Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB.Stream (0x800A0BBA) File could not be opened.

Status
Not open for further replies.

zakkar

Programmer
Dec 3, 2002
72
0
0
GR
Hello to you all
I'm trying to put the following asp
<%@language = VBScript%>
<%
Response.Buffer = True

FilePath = "C:\Inetpub\
Response.Clear

Set Stream = Server.CreateObject("ADODB.Stream")
Set FS = CreateObject("scripting.FileSystemObject")
Set F = FS.GetFile(FilePath)
FileSize = F.Size
FileName = F.Name
FilePath = F.Path


Stream.Open
Stream.Type = 1
Stream.LoadFromFile FilePath

FileType = lcase(Right(FileName, 4))
ForceDownload = True
TextStream = False
Select Case FileType
Case ".asf"
ContentType = "video/x-ms-asf"

Case ".avi"
ContentType = "video/avi"

Case ".zip"
ContentType = "application/zip"

Case ".xls"
ContentType = "application/vnd.ms-excel"

Case ".gif"
ContentType = "image/gif"
ForceDownload = False

Case ".jpg", "jpeg",".jpe"
ContentType = "image/jpeg"
ForceDownload = False

Case ".wav"
ContentType = "audio/wav"

Case ".mp3"
ContentType = "audio/mpeg3"

Case ".mpg", "mpeg",".mpe"
ContentType = "video/mpeg"

Case ".rtf"
ContentType = "application/rtf"

Case ".htm", "html"
ContentType = "text/html"
ForceDownload = False
TextStream = True

Case ".txt", ".cfg"
ContentType = "text/txt"
ForceDownload = False
TextStream = True

Case ".asp"
ContentType = "text/asp"
ForceDownload = False
TextStream = True

Case Else
ContentType = "application/octet-stream"
End Select

If Not TextStream Then
If ForceDownload Then
Response.AddHeader "Content-Disposition", "attachment;filename=" & FileName
Else
Response.AddHeader "Content-Disposition", "filename=" & FileName
End If
Response.AddHeader "Content-Length", FileSize
Response.Charset = "UTF-8"
Response.ContentType = ContentType

Response.BinaryWrite Stream.Read
Response.Flush
Else
Set F = FS.OpenTextFile(FilePath, 1,-2)
%>
<html>
<body>
<xmp>
<%=F.ReadAll%>
</xmp>
</body>
</html>
<%
F.Close
End If

Set F = nothing
Set FS = nothing
Stream.Close
Set Stream = Nothing
%>

so i can download the file from the browser.The file path is correct.
The above code is in a file named downloadxml.asp
The page which calls the downloadxml.asp is downloadcenter.asp and contains the following link
<a href="downloadxml.asp">
When i run it i get
Error Type:
ADODB.Stream (0x800A0BBA)
File could not be opened.

I cannot explain what is going on.
Any ideas or suggestions???
 
I had this problem yesterday!!! The problem was to do with the file path. I was pointing to the documents folder on my site incorrectly.

Try this for starters it works for me.

<%
Dim oStr
Dim sFile

sFile = Request.QueryString("file")
Set oStr = server.CreateObject("ADODB.Stream")
oStr.Open
oStr.LoadFromFile Server.MapPath("/documents/" & sFile)

Response.ContentType = "xxx/xxx"
Response.AddHeader "content-disposition", "attachment; filename=" & sFile
Response.BinaryWrite oStr.ReadText
%>

 
Still I get the same error.I says that i cannot open the file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top