PC Review


Reply
Thread Tools Rate Thread

How to copy a file from server to client

 
 
Shayer
Guest
Posts: n/a
 
      30th Aug 2003
Hello

I want to copy a file from server to client machine. How can i do that. I
may have to use byte stream but how can i do that . Pls tell me

THanks


 
Reply With Quote
 
 
 
 
Chris Taylor
Guest
Posts: n/a
 
      31st Aug 2003
Hi,

The System.IO namespace has a File class, this class has a static method
called Copy. Would this not do the trick for you?

Hope this helps

Chris Taylor
"Shayer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello
>
> I want to copy a file from server to client machine. How can i do that. I
> may have to use byte stream but how can i do that . Pls tell me
>
> THanks
>
>



 
Reply With Quote
 
Shayer
Guest
Posts: n/a
 
      31st Aug 2003
Hi Chris,

Thanks for your solution. ut i dont think it will work. Because i have a
server machine . when i start file copying using File.Copy ( ...) it will
copy the file into the server machine. But dont want that. I want to copy
the file to client machine which is running on separate computer.
Hope you may have a solution

Thanks

Shayer
"Chris Taylor" <(E-Mail Removed)> wrote in message
news:OG73#(E-Mail Removed)...
> Hi,
>
> The System.IO namespace has a File class, this class has a static method
> called Copy. Would this not do the trick for you?
>
> Hope this helps
>
> Chris Taylor
> "Shayer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello
> >
> > I want to copy a file from server to client machine. How can i do that.

I
> > may have to use byte stream but how can i do that . Pls tell me
> >
> > THanks
> >
> >

>
>



 
Reply With Quote
 
Chris Taylor
Guest
Posts: n/a
 
      31st Aug 2003
Hi,

To copy a file from a server you can setup a share on a server and do
something like the following

System.IO.File.Copy( @"\\hulk\c\data\test.doc", @"c:\test.doc" );

Where 'hulk' is the machine name, 'c' is the share name, 'data' is a folder
under that share and 'test.doc' is the file to copy.
'c:\test.doc' is the target on the local machine, where the file should be
copied to.

If what you want is to use FTP to transfere a file from the server to the
client, there are a few approaches, but you could take a look at the
following codeproject article as a starting point.

http://www.codeproject.com/dotnet/dotnetftp.asp

Hope this helps

Chris Taylor

"Shayer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Chris,
>
> Thanks for your solution. ut i dont think it will work. Because i have a
> server machine . when i start file copying using File.Copy ( ...) it will
> copy the file into the server machine. But dont want that. I want to copy
> the file to client machine which is running on separate computer.
> Hope you may have a solution
>
> Thanks
>
> Shayer
> "Chris Taylor" <(E-Mail Removed)> wrote in message
> news:OG73#(E-Mail Removed)...
> > Hi,
> >
> > The System.IO namespace has a File class, this class has a static method
> > called Copy. Would this not do the trick for you?
> >
> > Hope this helps
> >
> > Chris Taylor
> > "Shayer" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Hello
> > >
> > > I want to copy a file from server to client machine. How can i do

that.
> I
> > > may have to use byte stream but how can i do that . Pls tell me
> > >
> > > THanks
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Shayer
Guest
Posts: n/a
 
      31st Aug 2003
Hi Chris,

I have write this piece of code to my sremoting object, that is in ther
server and the file is also in the server;

----------------------------------------------------------------------------
----------------------------------
public string fileContent()
{
string
localfilepath="C:\\Subjects\\DOT\\CSharpProjects\\DataAccess\\tutorial2.mdb"
;
StreamReader r = new StreamReader ((System.IO.Stream)
File.OpenRead(localfilepath));
string con=r.ReadToEnd();
r.Close();
return con;
}
----------------------------------------------------------------------------
-----------------------------------

And my client also access that remote object and get the string and write to
local file by following method
----------------------------------------------------------------------------
----------------------------------
public void writeFile(string con)
{
string
localfilepath="D:\\Subjects\\DOT\\CSharpProjects\\DataAccess\\tute.mdb";
StreamWriter r = new StreamWriter((System.IO.Stream)
File.OpenWrite(localfilepath));
r.Write(con);
r.Close();
}
----------------------------------------------------------------------------
---------------------------------

But it can copy the file but it becomes corrupted.

Can you pls tell me where am i making mistake .

Thanks



"Chris Taylor" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Hi,
>
> To copy a file from a server you can setup a share on a server and do
> something like the following
>
> System.IO.File.Copy( @"\\hulk\c\data\test.doc", @"c:\test.doc" );
>
> Where 'hulk' is the machine name, 'c' is the share name, 'data' is a

folder
> under that share and 'test.doc' is the file to copy.
> 'c:\test.doc' is the target on the local machine, where the file should be
> copied to.
>
> If what you want is to use FTP to transfere a file from the server to the
> client, there are a few approaches, but you could take a look at the
> following codeproject article as a starting point.
>
> http://www.codeproject.com/dotnet/dotnetftp.asp
>
> Hope this helps
>
> Chris Taylor
>
> "Shayer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi Chris,
> >
> > Thanks for your solution. ut i dont think it will work. Because i have a
> > server machine . when i start file copying using File.Copy ( ...) it

will
> > copy the file into the server machine. But dont want that. I want to

copy
> > the file to client machine which is running on separate computer.
> > Hope you may have a solution
> >
> > Thanks
> >
> > Shayer
> > "Chris Taylor" <(E-Mail Removed)> wrote in message
> > news:OG73#(E-Mail Removed)...
> > > Hi,
> > >
> > > The System.IO namespace has a File class, this class has a static

method
> > > called Copy. Would this not do the trick for you?
> > >
> > > Hope this helps
> > >
> > > Chris Taylor
> > > "Shayer" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > Hello
> > > >
> > > > I want to copy a file from server to client machine. How can i do

> that.
> > I
> > > > may have to use byte stream but how can i do that . Pls tell me
> > > >
> > > > THanks
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Jon Skeet
Guest
Posts: n/a
 
      31st Aug 2003
Shayer <(E-Mail Removed)> wrote:

<snip>

> But it can copy the file but it becomes corrupted.
>
> Can you pls tell me where am i making mistake .


Yes - you're reading it as if it's a UTF-8 text file, which I rather
suspect it isn't. You should read and write byte arrays from the
stream, rather than using StreamReader and reading and writing strings.

Out of interest, why are you casting to Stream in the constructor for
StreamReader and StreamWriter? It's unnecessary as far as I can see.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy a file from client to server annamanthadoo@gmail.com Microsoft Dot NET 1 9th Feb 2007 03:47 AM
Browse client Directory to a specific folder and ftp the file from server to client bindu_conacle@yahoo.com Microsoft ASP .NET 1 26th Feb 2006 11:34 AM
question refined - Copy file from client to server =?Utf-8?B?Q0dX?= Microsoft Dot NET 9 8th Feb 2006 09:29 PM
File copy from client to server, newbie question =?Utf-8?B?Q0dX?= Microsoft Dot NET 3 7th Feb 2006 09:16 PM
File copy between terminal server(windows 2000 server) and remote desktop client sivaraj Microsoft Windows 2000 Terminal Server Clients 1 23rd Jul 2003 01:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:24 AM.