110,499
社区成员
发帖
与我相关
我的任务
分享
public void uploadFiles()
{
string resultFile = "";
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "文本文件|*.txt";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
resultFile = openFileDialog1.FileName;
string soursefilename = resultFile;
string fileName = openFileDialog1.SafeFileName;
string desname = "\\\\192.168.1.1\\user\\" + fileName + ".txt";
if (soursefilename == "" || desname == "")
{
MessageBox.Show("请选择文件和保存位置"); return;
}
File.Copy(soursefilename, desname, true);
MessageBox.Show("上传成功!");
}
}