string filePath = Form1.getProjectFilePath(); System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); //xmlDoc.Load(filePath); using (System.IO.FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (System.IO.StreamReader sr = new StreamReader(fs, Encoding.GetEncoding(936))) { var strXml = sr.ReadToEnd(); xmlDoc.LoadXml(strXml); } }
protected void abcBankPayment(string no, string amount, string productName, string qcode) { var buildingName = productName.Split(‘:‘)[0]; var bean = new ABCBankAccountBean(); DataContractJsonSerializer jsonSerial = new DataContractJsonSerializer(typeof(ABCBankAccountBean)); var result = File.ReadAllText(MapPath("~/Finance/ABCBankAccountMaping.json"), System.Text.Encoding.UTF8); using (MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(result))) { bean = (ABCBankAccountBean)jsonSerial.ReadObject(stream); } Building entityBuilding = bean.buildingItems.Where(exp => exp.buildingNames.Contains(buildingName)).FirstOrDefault(); if (entityBuilding == null) { //楼盘没有农行支付配置 getMsgLabel().Text = string.Format("楼盘‘{0}‘不能使用农行接口支付", buildingName); return; } }
XmlDocument.load 读文件报异常:文件正被其它线程使用,解决方法
原文:https://www.cnblogs.com/ioriwellings/p/12048810.html