Exemple #1
0
 public void SaveFile(UploadFileModel UploadFile, out string strFilePath)
 {
     // Store File to File System
     //string strVirtualPath = System.Configuration.ConfigurationManager.AppSettings["FileUploadLocation"].ToString();//权限系统没有文件路径配置
     string strNewFileName = string.Empty;
     string strVirtualPath = "/UploadedFiles/";
     if (!string.IsNullOrWhiteSpace(UploadFile.FileName))
     {
         strNewFileName = DateTime.Now.ToString("yyMMddhhmmss") + DateTime.Now.Millisecond.ToString() + UploadFile.FileName.Substring(UploadFile.FileName.LastIndexOf("."));
     }
     string strPath = System.Web.HttpContext.Current.Server.MapPath(strVirtualPath) + strNewFileName;
     if (System.IO.Directory.Exists(System.Web.HttpContext.Current.Server.MapPath(strVirtualPath)) == false)
     {
         System.IO.Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath(strVirtualPath));
     }
     System.IO.FileStream FileStream = new System.IO.FileStream(strPath, System.IO.FileMode.Create);
     FileStream.Write(UploadFile.File, 0, UploadFile.File.Length);
     FileStream.Close();
     FileStream.Dispose();
     strFilePath = strVirtualPath + strNewFileName;
 }
Exemple #2
0
 public bool ImportCityCSV(UploadFileModel uploadFile, Dictionary<string, string> empInfoDic, ref string strMsg)
 {
     string strPath = string.Empty;
     SaveFile(uploadFile, out strPath);//获取文件路径
     string strPhysicalPath = System.Web.HttpContext.Current.Server.MapPath(strPath);//到时测试strPath为空是是否报错
     using (SysDictionaryBLL bll = new SysDictionaryBLL())
     {
         return bll.ImportCityCSV(strPhysicalPath, empInfoDic, ref strMsg);
     }
 }