473,395 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Cannot find file error on Open dialog, Save works fine

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
Sep 15 '08 #1
0 1712

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Christopher Brandsdal | last post by:
Hi! I get an error when I run my code Is there any other way to get te information from my form? Heres the error I get and the code beneath. Line 120 is market with ''''''''''''Line...
1
by: Bob | last post by:
I am displaying a form with a datagrid populated from a select of database records which now exceed 12,000 when I select them all. The form displays just fine with all 12,000+ entries but when I...
4
by: Rob | last post by:
I have an Access application that allows users to open up certain files from within Access (.doc files with automation, .pdf's with a pdf viewing form). Other formats, we want to use Internet...
4
by: Dorte | last post by:
Hi, I am using the code below to stream a CSV file with the response object. Dim FileName As String = "Test.csv" With Web.HttpContext.Current.Response ...
0
by: Shawn Mehaffie | last post by:
I have the following class that I've wirtten to take a Dataset and automatically export it to either XML, ASCII or Tab delimited file. The reason I wrote it they way I did was that I don't want to...
1
by: jdhavo | last post by:
I'm trying to download an image file using XML from a web service. When the dialog box appears asking if I want to save the document or open it, If I click save and then open it, it works fine. If...
3
by: mo | last post by:
I have an application that uses Reporting Services. When the user chooses to print a report, they are taken to a window that allows them to fill in parameters for the report. They then click a...
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
0
by: =?Utf-8?B?RmlsZSBEb3dubG9hZCBQcm9ibGVt?= | last post by:
The File Download Dialog Box just disappears when either the Open or Save button is clicked on the Dialog Box, after I let the File Download Dialog Box stay there for more than three minutes. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.