public bool writeSdsData(sdsdata sds_data) { try { if (File.Exists("C:/jcdatatxt/" + sds_data.CarID + ".ini")) { File.Delete("C:/jcdatatxt/" + sds_data.CarID + ".ini"); } ini.INIIO.WritePrivateProfileString("检测结果", "车辆ID", sds_data.CarID, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "相对湿度", sds_data.Sd, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "环境温度", sds_data.Wd, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "大气压力", sds_data.Dqy, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "数值1", sds_data.λ_value, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "数值2", sds_data.Co_low, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "数值3", sds_data.Hc_low, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "数值4", sds_data.Co_high, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "数值5", sds_data.Hc_high, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "co2high", sds_data.Co2_high, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "o2high", sds_data.O2_high, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "co2low", sds_data.Co2_low, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "o2low", sds_data.O2_low, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "StartTime", sds_data.StartTime, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); ini.INIIO.WritePrivateProfileString("检测结果", "StopReason", sds_data.StopReason, "C:/jcdatatxt/" + sds_data.CarID + ".ini"); return(true); } catch { return(false); } }
public sdsdata readSdsData(string filePath) { sdsdata sds_data = new sdsdata(); try { StringBuilder temp = new StringBuilder(); temp.Length = 2048; if (File.Exists(filePath)) { ini.INIIO.GetPrivateProfileString("检测结果", "车辆ID", "", temp, 2048, filePath); sds_data.CarID = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "相对湿度", "", temp, 2048, filePath); sds_data.Sd = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "环境温度", "", temp, 2048, filePath); sds_data.Wd = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "大气压力", "", temp, 2048, filePath); sds_data.Dqy = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "数值1", "", temp, 2048, filePath); sds_data.λ_value = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "数值2", "", temp, 2048, filePath); sds_data.Co_low = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "数值3", "", temp, 2048, filePath); sds_data.Hc_low = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "数值4", "", temp, 2048, filePath); sds_data.Co_high = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "数值5", "", temp, 2048, filePath); sds_data.Hc_high = temp.ToString(); } else { sds_data.CarID = "-1"; } return(sds_data); } catch { sds_data.CarID = "-1"; return(sds_data); } }
public sdsdata readSdsData(string filePath) { sdsdata sds_data = new sdsdata(); try { StringBuilder temp = new StringBuilder(); temp.Length = 2048; if (File.Exists(filePath)) { ini.INIIO.GetPrivateProfileString("检测结果", "车辆ID", "", temp, 2048, filePath); sds_data.CarID = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "相对湿度", "", temp, 2048, filePath); sds_data.Sd = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "环境温度", "", temp, 2048, filePath); sds_data.Wd = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "大气压力", "", temp, 2048, filePath); sds_data.Dqy = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "数值1", "", temp, 2048, filePath); sds_data.λ_value = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "数值2", "", temp, 2048, filePath); sds_data.Co_low = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "数值3", "", temp, 2048, filePath); sds_data.Hc_low = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "数值4", "", temp, 2048, filePath); sds_data.Co_high = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "数值5", "", temp, 2048, filePath); sds_data.Hc_high = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "CO2HIGH", "", temp, 2048, filePath); sds_data.Co2_high = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "O2HIGH", "", temp, 2048, filePath); sds_data.O2_high = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "CO2LOW", "", temp, 2048, filePath); sds_data.Co2_low = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "O2LOW", "", temp, 2048, filePath); sds_data.O2_low = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "CrucialTime0", "", temp, 2048, filePath); sds_data.CrucialTime0 = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "CrucialTime1", "", temp, 2048, filePath); sds_data.CrucialTime0 = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "CrucialTime2", "", temp, 2048, filePath); sds_data.CrucialTime0 = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "CrucialTime3", "", temp, 2048, filePath); sds_data.CrucialTime0 = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "AmbientCO", "0", temp, 2048, filePath); sds_data.AmbientCO = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "AmbientHC", "0", temp, 2048, filePath); sds_data.AmbientHC = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "AmbientNO", "0", temp, 2048, filePath); sds_data.AmbientNO = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "ResidualHC", "0", temp, 2048, filePath); sds_data.ResidualHC = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "TestStartTime", "", temp, 2048, filePath); sds_data.TestStartTime = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "TestEndTime", "", temp, 2048, filePath); sds_data.TestEndTime = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "StartTime", "", temp, 2048, filePath); sds_data.StartTime = temp.ToString(); ini.INIIO.GetPrivateProfileString("检测结果", "StopReason", "", temp, 2048, filePath); sds_data.StopReason = temp.ToString(); } else { sds_data.CarID = "-1"; } return(sds_data); } catch { sds_data.CarID = "-1"; return(sds_data); } }