我前几天用到的
CTS_Wenjian wenjian = new CTS_Wenjian();
wenjian.userid = getUserInfo.id;
wenjian.riqi = DateTime.Now;
wenjian.filename = tb_name.Text.Trim();
wenjian.lbid = Convert.ToInt32(ddlLB.SelectedValue);
cts.CTS_Wenjian.InsertOnSubmit(wenjian);
cts.SubmitChanges();
if (!string.IsNullOrEmpty(file1.FileName))
{
CTS_File file = new CTS_File();
file.eventId = wenjian.id;
file.requisitionTypeId = Convert.ToInt32(Common.RequisitionTypeId.ImportantFile);
file.title = tb_name.Text.Trim();
string imgurl = "";
string name = tb_name.Text.Trim() + file1.FileName.Substring(file1.FileName.LastIndexOf('.'));
imgurl = Common.FileIsExists(Server.MapPath(filepath + name));
file.path = filepath + name;
file1.SaveAs(Server.MapPath(filepath + imgurl));
dd.CTS_File.InsertOnSubmit(file);
dd.SubmitChanges();
}
//图片上传获得图片的名称
System.IO.FileInfo info = new System.IO.FileInfo(this.flimageUrl.PostedFile.FileName);
string fileName = info.Name;
//保存图片到images文件夹
string filePath = "/images/upfiles/";
string tempFileName= System.DateTime.Now.Ticks.ToString() + info.Extension;
string realFilePath=Server.MapPath("~"+filePath);
this.flimageUrl.PostedFile.SaveAs(realFilePath+tempFileName);
一般好像只有上传文件的,上传文件夹的话,我想的是遍历文件夹,创建文件夹及所有子文件夹并拷贝其中的文件。