c#将本地文件上传至服务器(内网)
2021-02-11 14:19
标签:远程服务器 共享 style error file info out ice created 通过CMD连接远程服务器的方法 c#将本地文件上传至服务器(内网) 标签:远程服务器 共享 style error file info out ice created 原文地址:https://www.cnblogs.com/evanmemo/p/8492441.html //连接
string serverFolder = @"\\192.168.1.26\Invoice";//服务器的共享文件夹路径
string PWD = "666";//远程服务器密码
status = connectState(serverFolder, "Administrator", PWD);
if (status)
{
//共享文件夹的目录
DirectoryInfo theFolder = new DirectoryInfo(serverFolder);
string filename = theFolder.ToString();
//执行方法
if (File.Exists(serverFolder + @"\" + str_InvoiceName))//远程服务器上存在次文件那么下载,否则会报系统错误
{
TransportRemoteToLocal(destinationFile, serverFolder + @"\", str_InvoiceName); //实现将远程服务器文件写入到本地
}
//string destinationFile = Path_Folder + "\\" + str_InvoiceName.Remove(0, 17);
//file.CopyTo(destinationFile, true);
////File.Copy(sourceFile, "");
}
else
{
DevExpress.XtraEditors.XtraMessageBox.Show("不在内网,下载Invoice失败!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
///
将远程服务器文件写入到本地的方法
///