private ForumFile SaveAttachment(ForumPost post, HtmlInputFile file)
        {
            ForumFile fFile = new ForumFile();
            if(file.PostedFile==null || file.PostedFile.FileName.Trim().Length==0 || file.PostedFile.ContentLength==0)
                return null;

            string sUpDir = Server.MapPath(UrlHelper.GetApplicationPath() + "/Modules/Forum/Attach/");
            string filename = file.PostedFile.FileName;

            if(!System.IO.Directory.Exists(sUpDir))
            {
                System.IO.Directory.CreateDirectory(sUpDir);
            }

            int pos = filename.LastIndexOfAny(new char[]{'/','\\'});
            if (pos >= 0)
                filename = filename.Substring(pos+1);

            string newfilename = String.Format("{0}{1}.{2}",sUpDir,post.Id,filename);
            file.PostedFile.SaveAs(newfilename);
            fFile.OrigFileName = filename;
            fFile.ForumFileName = newfilename;
            fFile.FileSize = file.PostedFile.ContentLength;
            fFile.ContentType = file.PostedFile.ContentType;

            try
            {
                base.ForumModule.SaveForumFile(fFile);
            }
            catch(Exception ex)
            {
                throw new Exception("Unable to save file",ex);
            }
            return fFile;
        }
 public virtual void SaveForumFile(ForumFile forumfile)
 {
     ISession session = this._sessionManager.OpenSession();
     NHibernate.ITransaction tx = session.BeginTransaction();
     try
     {
         session.SaveOrUpdate(forumfile);
         tx.Commit();
         session.Close();
     }
     catch (Exception ex)
     {
         tx.Rollback();
         throw new Exception("Unable to save Forum file", ex);
     }
 }