如何将文件从一台PC复制到其他PC [英] How to copy file form one PC to other PC
本文介绍了如何将文件从一台PC复制到其他PC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个程序将文件从一个Pc复制到另一个Pc,我尝试使用File.Copy和In Textbox3我提供IpAddress与Path ex:@10.29.80.123 \\ newFolder程序没有给出例外和错误,但给出预期的输出。
请帮忙解决。
我尝试了什么:
private void btn_ChooseFile_Click( object sender,EventArgs e)
{
OpenFileDialog openFile = new OpenFileDialog();
openFile.ShowDialog();
textBox1.Text = openFile.FileName;
filename = textBox1.Text;
}
私有 void btn_Copy_Click( object sender,EventArgs e)
{
copy();
}
public void copy()
{
string sourceFileName;
string backup;
try
{
sourceFileName = Path.GetFileName(filename);
File.Copy(Path.Combine(filename,sourceFileName),Path.Combine(textBox3.Text,sourceFileName), true );
}
catch
{
MessageBox.Show( 找不到文件);
}
}
解决方案
尝试在路径的开头添加\\,例如\\10.29.80.123\\\
或作为ac#string:
ewFolder
string path = \\\\10.29.80.123\\ newFolder 跨度>;
i have a program to copy file form one Pc to other Pc ,i tried with File.Copy and In Textbox3 i am providing IpAddress with Path ex:@"10.29.80.123\\newFolder" program is not giving Exceptions and errors but giving Expected output.
Please help to resolve.
What I have tried:
private void btn_ChooseFile_Click(object sender, EventArgs e)
{
OpenFileDialog openFile = new OpenFileDialog();
openFile.ShowDialog();
textBox1.Text = openFile.FileName;
filename = textBox1.Text;
}
private void btn_Copy_Click(object sender, EventArgs e)
{
copy();
}
public void copy()
{
string sourceFileName;
string backup;
try
{
sourceFileName = Path.GetFileName(filename);
File.Copy(Path.Combine(filename, sourceFileName), Path.Combine(textBox3.Text, sourceFileName),true);
}
catch
{
MessageBox.Show("File Not Found");
}
}
解决方案
Try add \\ to the start of your path e.g\\10.29.80.123\newFolder
or as a c# string :
string path = "\\\\10.29.80.123\\newFolder";
这篇关于如何将文件从一台PC复制到其他PC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文