本文整理汇总了C#中WebService.venuesEntities.AddTotbl_file方法的典型用法代码示例。如果您正苦于以下问题:C# venuesEntities.AddTotbl_file方法的具体用法?C# venuesEntities.AddTotbl_file怎么用?C# venuesEntities.AddTotbl_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebService.venuesEntities
的用法示例。
在下文中一共展示了venuesEntities.AddTotbl_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string path = System.Configuration.ConfigurationManager.AppSettings["FilePath"].ToString()+"\\files";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
HttpFileCollection files = Request.Files;
if (files.Count == 0)
{
Response.Write("请勿直接访问本文件");
Response.End();
}
// 只取第 1 个文件
HttpPostedFile file = files[0];
if (file != null && file.ContentLength > 0)
{
using (venuesEntities db = new venuesEntities())
{
tbl_file kf = new tbl_file();
float m = (float)file.ContentLength / 1048576;
kf.Size =float.Parse( Math.Round(m,2).ToString());
kf.FileNameLocal = file.FileName;
string serverName = DateTime.Now.ToString("yyyyMMdd_HHmmss") + Path.GetExtension(Request.Form["fileName"]).ToLower();
kf.FileNameServer = "files/"+ serverName;
kf.FileUploadTime = DateTime.Now;
kf.FileUserID = int.Parse(Request.Params.Get("curUserID"));
kf.UserVenueTypeID = Request.Params.Get("curUserTypeParentID");
kf.Ext = System.IO.Path.GetExtension(file.FileName.ToLower()).Substring(1);
kf.DescribeInfo = Request.Params.Get("descript");
db.AddTotbl_file(kf);
db.SaveChanges();
string savePath = path + "\\" + serverName;
file.SaveAs(savePath);
}
}
}