Hi,
1)How transfer file from one PC to another?
2) are there different ways?
Thanks.
File
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Chintan RathodRank #516 · 4.8K reputationPosted May 27, 2012, 10:07 PM EDT
1) Using File object
======================
Syntax:
File.Copy(@"c:\csharp.txt",@"driveletter:\csharpcopy.txt");
Example:
File.Copy(@"c:\csharp.txt",@"d:\csharpcopy.txt");
2) Using xcopy ========================= using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Diagnostics; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { CopyFolder(@"c:\MyFolder", @"\\dinesh-PC\E$\MyFolder"); } private static void CopyFolder(string sourceFolder, string destFolder) { if (!Directory.Exists(destFolder)) Directory.CreateDirectory(destFolder); Process process1; using (process1 = new Process()) { process1.EnableRaisingEvents = true; string strcmd = sourceFolder + " " + destFolder + " /S"; process1.StartInfo.FileName = "xcopy"; process1.StartInfo.Arguments = strcmd; process1.StartInfo.WindowStyle = ProcessWindowStyle.Normal; process1.Start(); } } } } Thanks & Regards ---------------- Chintan Rathod