跨服务器保存文件:代码实现业务是将一个服务器上的文件保存到另一台服务器的共享目录下:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Windows.Forms;
 9 using System.IO;
10 
11 namespace 网络共享做本地映射
12 {
13     public partial class Form1 : Form
14     {
15         public Form1()
16         {
17             InitializeComponent();
18         }
19        
20 
21         string RemoteDirTo = @"\\Netnetnet-pc\站点发布"; //共享目录
22         string FilePathTo = @"\Test\";//共享目录(子目录)
23         string RemoteDirToUser = "admin2";//共享目录服务器用户
24         string RemoteDirToPwd = "123";//共享目录服务器密码
25         string RemoteDirFromFile = @"d:\aaaa.txt";//本地文件
26         string RemoteDirFromUser = "administrator";//本地用户
27         string RemoteDirFromPwd = "zmkm";//本地密码
28 
29         private void button3_Click(object sender, EventArgs e)
30         {
31             try
32             {
33                 DataExtractor.SaveFileToService(RemoteDirTo, FilePathTo, RemoteDirToUser, RemoteDirToPwd, RemoteDirFromFile, RemoteDirFromUser, RemoteDirFromPwd);
34             }
35             catch (Exception ex)
36             {
37                 MessageBox.Show(ex.Message);
38             }
39         }
40 
41 
42     }
43 }
View Code

相关文章:

  • 2021-07-12
  • 2021-09-20
  • 2022-12-23
  • 2021-07-02
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-29
  • 2021-08-15
  • 2021-05-27
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-08-20
相关资源
相似解决方案