內部網中不同機器間的文件上傳方法

內部網中不同機器間的文件上傳方法

1. ftp方法(需要建立ftp服務器)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

2. http方法(需要建立Web服務器)

3. 硬拷貝方法

以下爲硬拷貝方法的C#實現:

System.Diagnostics.ProcessStartInfo psi =              new System.Diagnostics.ProcessStartInfo();

              //環境變量取得ComSpec

              psi.FileName = System.Environment.GetEnvironmentVariable("ComSpec");

             

              psi.RedirectStandardInput = false;

              psi.RedirectStandardOutput = true;

              psi.UseShellExecute = false;

 

              //窗體不表示

              psi.CreateNoWindow = true;

 

              string cmnd = "";

              Process p = null;

 

              //連接到RemotePC

              cmnd = @"/C NET USE N: ////RemoteMachine//Abc /user:RemoteMachine//uid pass";

              psi.Arguments = cmnd;

              p = Process.Start(psi);

 

              //讀取出力

              results = p.StandardOutput.ReadToEnd();

              p.WaitForExit();

             

              //拷貝文件

              File.Copy(@"C://work//AAAAA.txt", @"N://BBBBB.txt");

 

              //斷開與RemotePC的連接

              cmnd = @"/C NET USE N: /delete";

              psi.Arguments = cmnd;

              p = Process.Start(psi);

              results = p.StandardOutput.ReadToEnd();

              p.WaitForExit();

發佈了28 篇原創文章 · 獲贊 1 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章