使用C#将文件从本地PC复制​​到服务器? [英] Copy file from local pc to server using C#?

查看:293
本文介绍了使用C#将文件从本地PC复制​​到服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我正在尝试将文件和文件夹从我的本地系统复制到服务器,但我得到的例外情况如

Hi All

I am trying to copy files and folders from my local system to server but i ma getting exception like

The network name cannot be found





可能是什么原因?如果没有其他方法将文件从本地发送到服务器请建议我链接





what may be the reason? if nay other approach to send file from local to server please suggest me link

 var fileName = "224_TestCases.xlsx";
                var local = Path.Combine(@"E:\ExcelModel\ExcelModel\TestPlan", fileName);
                var remote = Path.Combine(@"\\serverip\\c$\\", fileName);
                File.Copy(local, remote);

i am getting execption here  File.Copy(local, remote);







thanku



我尝试过:



var fileName = 224_TestCases.xlsx;

var local = Path.Combine(@E:\ ExcelModel \ ExcelModel \ TestPlan,fileName);

var remote = Path.Combine(@\\serverip \\c $ \\,fileName);

File.Copy(本地,远程);



i我在这里得到execption File.Copy(本地,远程);




thanku

What I have tried:

var fileName = "224_TestCases.xlsx";
var local = Path.Combine(@"E:\ExcelModel\ExcelModel\TestPlan", fileName);
var remote = Path.Combine(@"\\serverip\\c$\\", fileName);
File.Copy(local, remote);

i am getting execption here File.Copy(local, remote);

推荐答案

\\,fileName );
File.Copy(本地,远程);

i我在这里得到execption File.Copy(本地,远程);
\\", fileName); File.Copy(local, remote); i am getting execption here File.Copy(local, remote);







感谢



我尝试过的事情:



var fileName =224_TestCases.xlsx;

var local = Path.Combine(@E:\\ \\ ExcelModel \ ExcelModel \ TestPlan,fileName);

var remote = Path.Combine(@\\serverip\\c




thanku

What I have tried:

var fileName = "224_TestCases.xlsx";
var local = Path.Combine(@"E:\ExcelModel\ExcelModel\TestPlan", fileName);
var remote = Path.Combine(@"\\serverip\\c


\\,fileName);

File.Copy(本地,远程);



i我在这里得到execption File.Copy (本地,远程);
\\", fileName);
File.Copy(local, remote);

i am getting execption here File.Copy(local, remote);


1)确保获得服务器名称或IP地址是正确的,例如 \\192.168.1.2 \\servername

2)何时使用管理员共享,如 c
1) Make sure you get the server name or IP address is right e.g. \\192.168.1.2 or \\servername
2) When using the admin shares like c


这篇关于使用C#将文件从本地PC复制​​到服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆