如何在Windows应用程序中上传文件 [英] How to file upload in windows application
本文介绍了如何在Windows应用程序中上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DialogResult result = openDialog1.ShowDialog();
string fullpath = openDialog1.FileName;
string extension = Path.GetExtension(fullpath);
File.Copy(fullpath, @ C:\ Users \ Acer \ Documents\Visual Studio 2010 \Projects\sqlprocedure\sqlprocedure\Resources \Document\ + Filename + extension);
我尝试过:
我尝试 此但它采用相同的文件名。
我也无法获取路径其中复制文件位置文件是保存请帮帮我。
解决方案
你可以用它来获得完整的路径。
rfilename = openDialog1.InitialDirectory + openDialog1.FileName;
更改下面的文件名使用
FileInfo file = new FileInfo( c:\ test.txt);
file.Rename( test2.txt);
DialogResult result = openDialog1.ShowDialog();
string fullpath = openDialog1.FileName;
string extension = Path.GetExtension(fullpath);
File.Copy(fullpath, @"C:\Users\Acer\Documents\Visual Studio 2010\Projects\sqlprocedure\sqlprocedure\Resources\Document\" + Filename + extension);
What I have tried:
I Am try with this but it take same file name same.
I also cant get the path where copy file location File is save please help me.
解决方案
you can use this to get full path.
rfilename = openDialog1.InitialDirectory + openDialog1.FileName;
to change file name use below
FileInfo file = new FileInfo("c:\test.txt"); file.Rename("test2.txt");
这篇关于如何在Windows应用程序中上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文