怎样使用外部存储手段如使用配置文件等保存易变量,然后由程序读出。我想在客户处没有有编译环境的时候修改连接字符串? 常用得办法,就是读写INI文件,可以专门写这个读写得类 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以试试XML,在System.Xml命名空间里也可以试试.Net中的资源文件,在System.Resources 命名空间里这两个MSDN里都有比较详细的教程,可以参考 <?xml version="1.0" encoding="gb2312" ?> - <Config> <DBString>Provider=msdaora.1;User ID=dloco;Password=dloco;data source=dljc</DBString> <BuilderPath>\EntityData\</BuilderPath> <EntityPath>\EntityData\</EntityPath> </Config> so easy.use xml.以下是我的某个XML配置程序的代码段,你看了就知道如何做了.public void Save_ConfigXmlFile(string FileName) { XmlTextWriter myXmlTextWriter = new XmlTextWriter (FileName, null); myXmlTextWriter.Formatting = Formatting.Indented; myXmlTextWriter.WriteStartDocument(true); myXmlTextWriter.Indentation=4; myXmlTextWriter.WriteStartElement("Config",null); myXmlTextWriter.WriteStartElement("LocalSourceXmlFilePath",null); myXmlTextWriter.WriteRaw(this.LocalSourceXmlFilePath); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.WriteStartElement("LocalSourcePath",null); myXmlTextWriter.WriteRaw(this.localSourcePath); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.WriteStartElement("NetWorkSourceXmlFilePath",null); myXmlTextWriter.WriteRaw(this.netWorkSourceXmlFilePath); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.WriteStartElement("Target_UpLoadFilePath",null); myXmlTextWriter.WriteRaw(this.target_UpLoadFilePath); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.WriteStartElement("AutoRun",null); myXmlTextWriter.WriteRaw(this.autoRun); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.WriteEndElement(); /********************************************************************************/ myXmlTextWriter.Flush(); myXmlTextWriter.Close(); }public void Load_ConfigXmlFile(string XmlFileName) { XmlDocument XDoc = new XmlDocument(); XDoc.Load(XmlFileName); XmlNode XNod = XDoc.DocumentElement.SelectSingleNode("//LocalSourceXmlFilePath"); this.localSourceXmlFilePath=XNod.InnerText; XNod=XDoc.DocumentElement.SelectSingleNode("//LocalSourcePath"); this.localSourcePath=XNod.InnerText; XNod=XDoc.DocumentElement.SelectSingleNode("//NetWorkSourceXmlFilePath"); this.netWorkSourceXmlFilePath=XNod.InnerText; XNod=XDoc.DocumentElement.SelectSingleNode("//Target_UpLoadFilePath"); this.target_UpLoadFilePath=XNod.InnerText; XNod=XDoc.DocumentElement.SelectSingleNode("//AutoRun"); this.autoRun=XNod.InnerText; } 如何在Form1中实现单击新建按钮后弹出Form2来采集信息,这时候Form1不可访问 【求助】C# 对话框如何自己添加控件?或者改写系统自带的控件? C# 取IE访问历史记录 用接口方式 [300分]Oracle性能优化的问题 菜鸟急求方法 C#如何实现鼠标拖拽呢? C#文件问题 如何解决 winForm程序打包 窗体load事件,请帮助 简单问题,DateTime.tostring(""),如何格式化保证为2003-12-30 二维数组如何绑定DropDownList1! 关于RangeValidator 控件问题!
- <Config>
<DBString>Provider=msdaora.1;User ID=dloco;Password=dloco;data source=dljc</DBString>
<BuilderPath>\EntityData\</BuilderPath>
<EntityPath>\EntityData\</EntityPath>
</Config>
以下是我的某个XML配置程序的代码段,你看了就知道如何做了.
public void Save_ConfigXmlFile(string FileName)
{
XmlTextWriter myXmlTextWriter = new XmlTextWriter (FileName, null);
myXmlTextWriter.Formatting = Formatting.Indented;
myXmlTextWriter.WriteStartDocument(true);
myXmlTextWriter.Indentation=4;
myXmlTextWriter.WriteStartElement("Config",null);
myXmlTextWriter.WriteStartElement("LocalSourceXmlFilePath",null);
myXmlTextWriter.WriteRaw(this.LocalSourceXmlFilePath);
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.WriteStartElement("LocalSourcePath",null);
myXmlTextWriter.WriteRaw(this.localSourcePath);
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.WriteStartElement("NetWorkSourceXmlFilePath",null);
myXmlTextWriter.WriteRaw(this.netWorkSourceXmlFilePath);
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.WriteStartElement("Target_UpLoadFilePath",null);
myXmlTextWriter.WriteRaw(this.target_UpLoadFilePath);
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.WriteStartElement("AutoRun",null);
myXmlTextWriter.WriteRaw(this.autoRun);
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.WriteEndElement();
/********************************************************************************/
myXmlTextWriter.Flush();
myXmlTextWriter.Close();
}
public void Load_ConfigXmlFile(string XmlFileName)
{
XmlDocument XDoc = new XmlDocument();
XDoc.Load(XmlFileName);
XmlNode XNod = XDoc.DocumentElement.SelectSingleNode("//LocalSourceXmlFilePath");
this.localSourceXmlFilePath=XNod.InnerText;
XNod=XDoc.DocumentElement.SelectSingleNode("//LocalSourcePath");
this.localSourcePath=XNod.InnerText;
XNod=XDoc.DocumentElement.SelectSingleNode("//NetWorkSourceXmlFilePath");
this.netWorkSourceXmlFilePath=XNod.InnerText;
XNod=XDoc.DocumentElement.SelectSingleNode("//Target_UpLoadFilePath");
this.target_UpLoadFilePath=XNod.InnerText;
XNod=XDoc.DocumentElement.SelectSingleNode("//AutoRun");
this.autoRun=XNod.InnerText;
}