473,789 Members | 2,431 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Streaming a File from a Web Service

Hello, I am trying to have a desktop application receive a file from a web
service. I am not sure how to do this, This is the Web Service Function.
This is a webmethod that takes a file and convert it back out to a Binary
Stream

<WebMethod()> _
Public Function StartDownload() As Byte()
Dim fs As FileStream

Try
' Read file and return contents
Dim serverPath As String = "C:\Test1.W MA"
fs = File.Open(serve rPath, FileMode.Open, FileAccess.Read )

Dim lngLen As Long = fs.Length
Dim abytBuffer(CInt (lngLen - 1)) As Byte
fs.Read(abytBuf fer, 0, CInt(lngLen))
Return abytBuffer

Finally
' Make sure that file stream is
' closed even if an error occurs.
fs.Close()
End Try
End Function

I have noticed that when this code is implemented it does not cause the
client computer to open a download dialogbox. I am assuming that I have to
implement code to receive the file then write it to the clients computer.
Is this correct. The Web Service is being called from a Desktop
Application. I am having a struggle trying to implement this.

Client Computer (Desktop Computer)

fs = New IO.FileStream(" C:\Me.wma", IO.FileMode.Cre ate, IO.FileAccess.W rite)
Dim BW As New IO.BinaryWriter (fs)
Dim leng As Integer = fs.Length
Dim abytBuffer(CInt (leng - 1)) As Byte
fs.Write(abytBu ffer, 0, CInt(leng))
' This causes the file to be 0 in length
Dim serverPath As String = "C:\Test1.W MA"
fs = New IO.FileStream(T heService.Start Download, IO.FileMode.Ope nOrCreate)
Dim BW As New IO.BinaryWriter (fs)
Dim AByte() As Byte = TheService.Star tDownload()the service
Dim AByte1 As Byte
For Each AByte1 In AByte
bw.write(Abyte1 )
next
'This Causes the File to write Gigs and Gigs of data to the file Test1.WMA

Thanks again for your assistance,
Chuck


Nov 18 '05 #1
0 1033

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

Similar topics

4
8178
by: A.M-SG | last post by:
Hi, I have a ASP.NET aspx file that needs to pass large images from a network storage to client browser. The requirement is that users cannot have access to the network share. The aspx file must be the only method that users receive image files.
3
6217
by: Rob | last post by:
I have an ASP.Net web app that generates a Crystal Report in PDF format. Since there is sensitive data within the reports, the pdfs need to be streamed to the browser then deleted immediately. The report gets kick off by a Java application redirecting the URL to the ASP.Net app on the IIS Server with all report selection criteria appended to the querystring. The Crystal Report is rendered in a new window. In the Page_Load() event, I...
3
1460
by: Casper Hornstrup | last post by:
I have an ASP.NET application that imports product descriptions from an Excel file. The Excel file is uploaded, then a background thread will start importing the product descriptions from the Excel file. When the Excel file is uploaded, the user's browser is redirected (using Response.Redirect) to a new page that will stream some javascript to show the progress of the import. I do perform a Response.Flush() after each script tag. I've...
2
6080
by: Stu | last post by:
Hi, I have encrypted pdf files which I need to stream through a web service to the browser. So I have a byte() array returned from my web service call which allows me to decrypt back to the pdf before displaying. It works but is slow when the average report is 84K. So basically I need to speed up the streaming. I have tried gzip compression but found out that pdf are already compressed using flate algorithm so no luck there. I tried...
7
9765
by: CJM | last post by:
I have a page on our intranet that is supposed to stream an Excel sheet to the user. I'm using pretty standard code: sFilePath = sFileDir & sFilename Response.AddHeader "content-disposition","attachment; filename=" & sFilePath ' Create your header information Response.ContentType = "application/x-msexcel"
7
9907
by: Douglas McCormick | last post by:
Hello, I am looking for the best way to securely stream a PDF to the browser (IE). The PDF would be inside our firewall, so presumably there would have to be some sort of middle-tier app inside the firewall that would receive a request from a browser and then get the PDF and stream it outside the firewall to the browser. Does that make sense?
5
3554
by: pmakoi | last post by:
dear all this might be a piece of cake for some of you out there but it is causing me a lot of stress given the fact that there is not enogh documentation out there regarding this topic I am writing a web service that uses soap with attachments to send a large streaming data, The concept works quite well but when I started to test it I got this problem. When my client program calls a method that should return a real time data the...
3
4042
by: Brad | last post by:
I have an aspx page that is sending pdf files to client browsers: it uses a filestream to read the pdf file and response.binarywrite to send content to the browser. This has worked great for years in IE, Firefox and Opera on windows, and it works on a Mac with Firefox and Opera. But this fails in Safari with the generic message "A network error occurred while accessing this document". Here is a link to try out ...
1
2862
by: Faisal Shafiq | last post by:
I want to upload a file direct to the Silverlight Streaming Service from a Web Client such as silverlight application. As per our product requirement we want to upload a .WMV file directly from silverlight client to Silverlight streaming service. I tried to user WebClient and HttpWebRequest for that purpose but, unfortunately I can found the way to do so. There are some problems with both classes. 1. There is no property of get...
0
9663
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10404
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10193
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6761
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4089
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.