public RedirectResult UploadDictionary(FormCollection form)
{
if (Request.Files.Count > 0)
{
var file = Request.Files[0];
if (file != null && file.ContentLength > 0)
{
using (var session = NHibernateHelper.OpenSession())
{
using (StreamReader streamReader = new StreamReader(file.InputStream))
{
while (!streamReader.EndOfStream)
{
var dictionary = new FSDictionary();
dictionary.Word = streamReader.ReadLine().Trim().ToLower();
dictionary.PIDId = Convert.ToInt32(form["id"]);
dictionary.DateAdded = DateTime.Now;
dictionary.AddedBy = User.Identity.GetUserName();
session.Save(dictionary);
}
}
}
}
}
return Redirect(Request.UrlReferrer.ToString());
}
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2017
(142)
-
▼
October
(10)
- How long is a .NET DateTime/TimeSpan tick?
- Fractional Seconds in Time Values
- Powershell DB Restore
- Remove time from SQL Date
- SQL Database Restore
- ASP.NET MVC 4 partial view
- Fluent NHibernate Deleting multiple objects
- Uploading a File (Or Files) With ASP.NET MVC
- Bootstrap Varying modal content
- How to read the content of the file using Fileupload
-
▼
October
(10)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.