Connecting Tech Pros Worldwide Forums | Help | Site Map

Cannot find file error on Open dialog, Save works fine

TaraPriest@gmail.com
Guest
 
Posts: n/a
#1: Sep 16 '08
Hi all,

I've got a vb.net web application that is using a web service to
stream documents from a repository. Once the service feeds me the
document I'l downloading it using the browser response functions. If
I choose to Save it works every time. If I choose to open the file I
get an error saying the file cannot be found, create a new file? The
save does occassionally work, every other attempt at best. Any ideas
would be appreciated!

Here is my code...

Private Sub RetrieveDocument(ByVal e As Integer)

Dim dr As DataRow
Dim f As Byte()
Dim dtVFDocs As DataTable
Dim DocKey As Integer
Dim DownloadFileName As String

dtVFDocs = Session("VirturalFolderContents")
dr = dtVFDocs.Rows(e)
DocKey = dr("Key")
DownloadFileName = CreateDownloadFileName(dr("DocTypeName"),
dr("OriginalFileName"), dr("StoragePath"))

'Create web service object
Dim a As New WAS.WebArchiveService

'Execute web service function and return results
f = a.GetDocument(Session("CompanyID").ToString,
Session("ConnectionString").ToString, Session("User"), DocKey)

If UBound(f) 0 Then
'send file back to client browser if the file isn't 0
bytes
Response.Clear()
Response.AppendHeader("Content-Disposition", "attachment;
filename=" & DownloadFileName)
Response.AppendHeader("Content-Length", UBound(f))
Response.ContentType = "application/octet-stream"
Response.ContentType = "text/plain"
Response.Flush()
Response.BinaryWrite(f)
Response.End()
End If

'cleanup
a = Nothing
f = Nothing
dr = Nothing
dtVFDocs = Nothing


End Sub

Closed Thread