62,268
社区成员
发帖
与我相关
我的任务
分享
protected void MoveFiles()
{
//filePath = FileUpload1.PostedFile.FileName; //你这个是读取到的客户端文件的绝对路径
/*
因为B/S系统不能直接操作客户端的文件,所以,
接下来,你要把这个上传的文件保存到你的服务器的某个目录下,
假设你的服务器存放这个上传的文件的目录是D:\A\
*/
if(filePath != "")
{
this.FileUpload1.SaveAs(@"D:\A\");
string fileP = Server.MapPath(@"D:\A\a.xls");
string newFileName = DateTime.Now.Ticks.ToString() + ".xls";
string strSavePath = Server.MapPath("./DataFiles/") + newFileName;
// 将A文件夹内的a.xls移动到B文件夹内
System.IO.File.Move(fileP, strSavePath);
}
}
protected void MoveFiles()
{
filePath = FileUpload1.PostedFile.FileName; //这个是读取到的绝对路径
/*
因为B/S系统不能直接操作客户端的文件,所以,
接下来,你要把这个上传的文件保存到你的服务器的某个目录下,
假设你的服务器存放这个上传的文件的目录是D:\A\
*/
string fileP = Server.MapPath(@"D:\A\a.xls");
string newFileName = DateTime.Now.Ticks.ToString() + ".xls";
string strSavePath = Server.MapPath("./DataFiles/") + newFileName;
// 将A文件夹内的a.xls移动到B文件夹内
System.IO.File.Move(fileP, strSavePath);
}
protected void MoveFiles()
{
string sourceFileAdress = @"D:\A\a.xls";
string destinationFileAdress = @"D:\B\a.xls";
// 将A文件夹内的a.xls移动到B文件夹内
System.IO.File.Move(sourceFileAdress, destinationFileAdress);
}