我正在向视频添加一行,然后我想使用与视频的物理文件名相同的 ID。所以我需要添加没有文件名的行,然后使用我得到的 ID,然后用文件名更新该行。我现在才确定该怎么做。
public ActionResult UpVideo(Report Report, string VideoName, HttpPostedFileBase file)
{
Video v = new Video();
v.Name = VideoName;
v.Report = Report;
db.Videos.Add(v);
var filename = v.ID + "." + Path.GetExtension(file.FileName);
var path = Path.Combine(Server.MapPath("~/App_Data/video_uploads"), filename);
file.SaveAs(path);
v.FileName = filename;
//** update Row here with filename
db.SaveChanges();
//** redirect back to Report Details (need to figure out how do do this too)
return RedirectToAction(Report);
}