问题描述
- c# 解压文件的 解压之后没有存进数据库 没有看的解压之后 文件
-
Stream stream = HttpContext.Current.Request.InputStream; account = HttpContext.Current.Request.Params["Account"]; if (account == null || account == "") { account = "unknown"; } desZipFilePrefix = ServiceHelp.getDesZipFileName(account); fileSuffixNme = ".rar"; //读取文件流将文件保存到服务器的特定目录下 compressFilePath = OperateZipFile.writeCompressFile(stream, desZipFilePrefix + fileSuffixNme); if (Directory.Exists(System.Web.HttpContext.Current.Server.MapPath("DesFile")) == false) { Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath("DesFile")); } deCompressFilePath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("DesFile"), desZipFilePrefix); OperateZipFile.UnRar(deCompressFilePath, compressFilePath, desZipFilePrefix + fileSuffixNme); //解析shapefile文件 FeatureShapeFileParse featureShapeFileParse = new FeatureShapeFileParse(); featureShapeFileParse.filePathForShp = featureShapeFileParse.getShpPath(deCompressFilePath); featureShapeFileParse.filePathForShx = featureShapeFileParse.getShxPath(deCompressFilePath); featureShapeFileParse.filePathForDbf = featureShapeFileParse.getDbfPath(deCompressFilePath); List<ShpFileData> shpFileDataList = featureShapeFileParse.readShpFile(); List<DbfFileData> dbfFileDataList = featureShapeFileParse.readDbfile(); if (dbfFileDataList == null) { new Normal_AdminlogsDAL().SaveMapServiceLog(" 解压失败,或者文件为空"); return; } SurveyFeatureAddRequest surveyFeatureAddRequest = getSurveyFeatureAddRequest(shpFileDataList, dbfFileDataList); string featureSql = string.Format(" INSERT INTO [PRO_PollingCheckLog]([P_ProID],[P_UserID],[P_CheckLogName],[P_StartTime],[P_EndTime],[P_Attributes],[P_LayerName],[P_FeatureName],[P_PicURI],[P_MediaURI],[P_Note],[P_StatusID],[P_CreateUserName],[P_CreateTime]) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}',getdate() ) ;", surveyFeatureAddRequest.ProjectID, surveyFeatureAddRequest.SysUserId, surveyFeatureAddRequest.ProjectName, surveyFeatureAddRequest.SurveyTime, surveyFeatureAddRequest.SurveyTime, surveyFeatureAddRequest.Attributes, surveyFeatureAddRequest.LayerName, surveyFeatureAddRequest.FeatureName, surveyFeatureAddRequest.PicURI, surveyFeatureAddRequest.MediaURI, surveyFeatureAddRequest.Note, 1, account); int exerst = new SurveyFeatureDAL().InsertSurveyFeature(featureSql); if (exerst > 0) { //删除解压后的临时文件 deleteTempFile(); //记录用户操作日志 //new Normal_AdminlogsDAL().SaveLog(surveyFeatureAddRequest.SysUserId.ToString(), "项目名称:" + surveyFeatureAddRequest.ProjectName + ",关联地物信息已经上传成功。"); } else { new Normal_AdminlogsDAL().SaveMapServiceLog("插入失败");//Test
dbfFileDataList 总是等 null
解决方案
你的压缩文件是什么类型,单独执行解压缩是否正确,或者报什么错误。
解决方案二:
c# 压缩解压文件
解决方案三:
OperateZipFile.UnRar 调用失败了
估计你传入的参数格式可能不正确等,所以失败了
解决方案四:
应该是参数不正确。。。。。。。
时间: 2025-01-27 02:59:13