I'm wiritng a dot.net windows forms appliction that needs to connect to a
webservice to download some files.
I need to show a progress bar during the download, bacause some file can be
very big.
How Can i Mkae this?
Can i use a stream?
There are some samples?
I'm thinking to use a byte array to get, for each call, a chunck of bytes,
but I think also that in this way i'll made a lot of HTTP calls...
Thank you 3 2739
Hi Tom,
I use a service like that:
<%@ WebService Language="C#" Class="Manage_D ocument" %>
using System.Configur ation;
using System;
using System.Xml;
using System.Web;
using System.Web.Serv ices;
using System.Web.Serv ices.Protocols;
using System.IO;
using Hss.Com.WebServ ices.Exceptions Handler;
[WebService(Name space = "http://here.is.your.na mespeace")]
[WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
public class Manage_Document : System.Web.Serv ices.WebService {
protected string _file_path =
"C:\\Inetpub\\w wwroot\\Hss.Com .WebServices\\P ictures\\";
[WebMethod]
public bool SaveDocument(By te[] docbinaryarray, string docname) {
try {
string strdocPath;
strdocPath = _file_path + docname;
FileStream objfilestream = new FileStream(strd ocPath,
FileMode.Create , FileAccess.Read Write);
objfilestream.W rite(docbinarya rray, 0,
docbinaryarray. Length);
objfilestream.C lose();
} catch(Exception e) {
SoapExceptionMa nager mger = new
SoapExceptionMa nager(Namespace s.WebService);
mger.SetExcepti on(e);
SoapException se = new SoapException(" Fault occured",
SoapException.C lientFaultCode, Context.Request .Url.AbsoluteUr i,
mger.GetExcepti onNode());
throw se;
}
return true;
}
[WebMethod]
public int GetDocumentLen( string DocumentName) {
string strdocPath;
strdocPath = _file_path + DocumentName;
int len;
try {
FileStream objfilestream = new FileStream(strd ocPath,
FileMode.Open, FileAccess.Read );
len = (int)objfilestr eam.Length;
objfilestream.C lose();
} catch(Exception e) {
SoapExceptionMa nager mger = new
SoapExceptionMa nager(Namespace s.WebService);
mger.SetExcepti on(e);
SoapException se = new SoapException(" Fault occured",
SoapException.C lientFaultCode, Context.Request .Url.AbsoluteUr i,
mger.GetExcepti onNode());
throw se;
}
return len;
}
[WebMethod]
public Byte[] GetDocument(str ing DocumentName) {
string strdocPath;
strdocPath = _file_path + DocumentName;
Byte[] documentcontent s;
try {
FileStream objfilestream = new FileStream(strd ocPath,
FileMode.Open, FileAccess.Read );
int len = (int)objfilestr eam.Length;
documentcontent s = new Byte[len];
objfilestream.R ead(documentcon tents, 0, len);
objfilestream.C lose();
} catch(Exception e) {
SoapExceptionMa nager mger = new
SoapExceptionMa nager(Namespace s.WebService);
mger.SetExcepti on(e);
SoapException se = new SoapException(" Fault occured",
SoapException.C lientFaultCode, Context.Request .Url.AbsoluteUr i,
mger.GetExcepti onNode());
throw se;
}
return documentcontent s;
}
}
I found the base of this code somewhere online but there was no licence
on it, feel free to use and modify it at your will. The Soap Exceptions
Handler is home made, but I can give that as well if anybody needs it
;)
I hope this help.
Best regards,
Pierre
Using this code i am unable to show a progress bar because with the
getdocument method i get all the byte array..
If a file is large (es 20 MB) the time needed is too high! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jagdeesh |
last post by:
Hai Colleagues,
I am using Tomcat 4.1.24 and JDK 1.4.0_03 in my winXP machine. I've
transferred a set of folders(containing jsp files) into tomcat's
webapps directory(to /webapps/bob , /webapps/sue) and i have added the
folders bob, sue in my server.xml(in the context path).
When i am trying to run jsp files from my browser, it works fine. But,
the following jsp files reports some exceptions which is quite hard to
understand. Here is...
|
by: Navin |
last post by:
hi,
guys i am using the following code to force a file download dialog in
asp
Response.ContentType = "application/vnd.ms-excel"
response.AddHeader "content-disposition","attachment; filename=" &" &
StrFileName
Now the it works fine in ie5.5 sp2 but no ie5.5 sp1 it prompts the
user twice the open dialog box.
|
by: Eric Caron |
last post by:
Hi
Here's my problem, I create a windows service with Config.xml file.
All setup for my service is in this file. I create a windows
application to manage these settings (Config.XML File). This work good
if the two applications are in the same folder and Config.XML is in
the folder too but If not, my windows application setting don't work.
In my windows form I have a Service controler components to manage my
service (start, stop, ...)....
|
by: Kevin Muenzler, WB5RUE |
last post by:
How do I force a browser to download a file instead of displaying it? In
other words I have a page with MP3 and WMA files on it and I would like for
the visitor to download the file instead of play it without having to
right-click and save.
How can I force the browser to pop up the "save file as" dialog box instead
of playing it? I know that I can encapsulate it in a zip file which will
download and open WinZip.
Thanks
|
by: Andy Johns |
last post by:
I've seen plenty of examples of file uploads in ASP.NET when the only
form element is the file input type, but I've not seen a practical
example of a file upload routine running alongside other form
elements, e.g. a text box for a description for example. If the form
is being posted in multipart format then the text coming through will
need to be converted first, won't it?
The other issue is that if the form is posted, and the...
| |
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
by: Suman |
last post by:
Happy Friday everyone!!!
I am working on a windows service and a C# application and needed some
help with certain functionality. Please read through my issue below.
Thanks!
I have a windows service which writes into a log file periodically
(text file). I want to create a windows form application, which, upon
invocation should continuously display the contents of the log file.
Even the newly made entries into the log file while the...
|
by: noah.blumenthal |
last post by:
I wrote a windows service in c# (applause) and now I want to
add the ability to edit its settings. Basically this service checks an
email account at certain intervals and forwards the emails to another
email address. I want to be able to configure how often it runs (it
uses a timer, so setting the interval for that timer is what I mean by
that statement) and what account to check and what email address to
send to.
Seems easy, right? ...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |