473,394 Members | 1,693 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,394 software developers and data experts.

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.WMA"
fs = File.Open(serverPath, FileMode.Open, FileAccess.Read)

Dim lngLen As Long = fs.Length
Dim abytBuffer(CInt(lngLen - 1)) As Byte
fs.Read(abytBuffer, 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.Create, IO.FileAccess.Write)
Dim BW As New IO.BinaryWriter(fs)
Dim leng As Integer = fs.Length
Dim abytBuffer(CInt(leng - 1)) As Byte
fs.Write(abytBuffer, 0, CInt(leng))
' This causes the file to be 0 in length
Dim serverPath As String = "C:\Test1.WMA"
fs = New IO.FileStream(TheService.StartDownload, IO.FileMode.OpenOrCreate)
Dim BW As New IO.BinaryWriter(fs)
Dim AByte() As Byte = TheService.StartDownload()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 1018

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

Similar topics

4
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...
3
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...
3
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...
2
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...
7
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...
7
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...
5
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...
3
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...
1
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...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...

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.