本文整理汇总了C#中FileManager.createDocument方法的典型用法代码示例。如果您正苦于以下问题:C# FileManager.createDocument方法的具体用法?C# FileManager.createDocument怎么用?C# FileManager.createDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager.createDocument方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: uploadBtn_Click
protected void uploadBtn_Click(object sender, EventArgs e)
{
if (fu.HasFile && fu.FileContent.Length != 0)
{
using (var context = new PetoEntities())
{
try
{
// create new instance of a document
Document d = new Document();
// populate this instance
d.name = fu.FileName;
// divide by 1000 to convert bytes to kilobytes
d.size = fu.PostedFile.ContentLength / 1000;
d.MIMEType = fu.PostedFile.ContentType;
d.DateCreated = DateTime.Now;
d.DateModified = DateTime.Now;
d.fileContent = fu.FileBytes;
d.extension = Path.GetExtension(fu.PostedFile.FileName).Substring(1);
d.Role = permissionDDL.SelectedItem.Value;
// d.Category = typeDDL.SelectedValue;
// save changes to the database
FileManager fm = new FileManager();
fm.createDocument(d);
// show success
statusLbl.ForeColor = System.Drawing.Color.Green;
statusLbl.Text = "File Successfully Uploaded";
}
catch (Exception ex)
{
// shoe error message
statusLbl.ForeColor = System.Drawing.Color.Red;
statusLbl.Text = "Error: File was not uploaded due to: " + ex.Message;
throw;
}
}
}
else
{
statusLbl.ForeColor = System.Drawing.Color.Red;
statusLbl.Text = "Error: No File Chosen";
}
}