WebClient Not posting to Client

T

Tom

Anyone know how to post a file to the client using
WebClient?
My usage is posting it to the Web Server.
How do you tell the object to post to the client?

I copied the code from the Microsoft site for examples of
text file downloads using WebClient, but it only copies
to the Web Server. I've tried the 'DownloadFile'
function, obviously, as well.

.... (it reads just fine.)
string TheirAddress = "C:\\temp\\client.zip";
System.IO.Stream TheirStream = MyClient.OpenWrite
(TheirAddress);

byte [] buf = new byte[1024];
int len = 0;
//loop through the stream and put the output in the
textbox.
while((len = MyStream.Read(buf,0,buf.Length))!=0)
{
//textOutput.AppendText(NewLine+"\r\n");
TheirStream.Write(buf,0,len );
}
 
T

Tom

Sorry. I used the wrong terminology.
I meant the WebClient class is not DOWNLOADING a file to
the client. The Web Server copies the file to itself when
using destination: "C:\\temp\\client.zip". I would have
thought that the WebClient class would take this path to
be on the Client--- but it does not. It takes the path to
be on the Web Server that it is executing on.

I was wondering how do you tell the WebClient class to
copy the file to the Clients' hard drive?...from the info
I've been reading, this is what I was led to believe was
the functionality of "WebClient". It seems I'm missing a
piece of the puzzle... of how to 'Focus' the WebClient
class to the client. Is there something in the background
I need to be setting?

Uploading from client to Web Server seems to be a piece
of cake. There are plenty of options to use for that and
they all seem to work. Thanks.

Hope you follow this thread. I appreciate you responding.
-----Original Message-----
Try the WebRequest class if you want to POST data to a web server. The
WebClient class expects a that's able to handle the file upload, for
example file the file upload server control, at the destination.

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko


-----Original Message-----
From: Tom [mailto:[email protected]]
Posted At: Tuesday, February 01, 2005 10:38 AM
Posted To: microsoft.public.dotnet.framework.aspnet.webservices
Conversation: WebClient Not posting to Client
Subject: WebClient Not posting to Client

Anyone know how to post a file to the client using
WebClient?
My usage is posting it to the Web Server.
How do you tell the object to post to the client?

I copied the code from the Microsoft site for examples of
text file downloads using WebClient, but it only copies
to the Web Server. I've tried the 'DownloadFile'
function, obviously, as well.

... (it reads just fine.)
string TheirAddress = "C:\\temp\\client.zip";
System.IO.Stream TheirStream = MyClient.OpenWrite
(TheirAddress);

byte [] buf = new byte[1024];
int len = 0;
//loop through the stream and put the output in the
textbox.
while((len = MyStream.Read(buf,0,buf.Length))!=0)
{
//textOutput.AppendText(NewLine+"\r\n");
TheirStream.Write(buf,0,len );
}

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top