安装后,我们的app.config文件参数值使用c#.net接受更改 [英] after instalation our app.config file parameter value accepting changes using c#.net
问题描述
你好
iam开发win应用程序,用于从系统位置检索图像并将其转换为文本文件并保存到系统位置,这是我的工作. 我要在安装后接受app.config文件的更改.在这里,用户修改app.config文件的参数值(在此提及驱动器地址),这意味着在不进行编译的情况下exe可以接受该远程系统中的更改. /b>例如,iam在一个系统中创建了一个winapp设置文件并部署了
我对系统中的固定位置有一个想法
我的代码是(这是从总代码中得到的和平)
hello
iam developing win application for retrive the image from system location and converting into text file and save into system location this is my work. i want to accept the changes of app.config file after instalation.here user modify the app.config file parameter value(here mention the drive address) ,that means with out compilation the exe accept changes in that remote system.for example iam created one winapp setup file and deployee in one system.
aftrer he change the app.config file parameter(this containing system drive location) at that time my application accept that drive address and do iamge process.
i have an idea for fixed location in system
my code is(This is peace of from total code)
<appSettings>
<add key="SQLCN" value="Data Source=localhost;Initial Catalog=MyDB;Integrated Security=True" />
<add key="IMGFOLDER" value="D:\\ImageFolder"/>
<add key="SaveImagefolderPath" value="D:\\SaveImageOutPutFolder" / </appSettings>
string fldr = ConfigurationSettings.AppSettings["IMGFOLDER"];
Formload()
{
NewImageFolderCreation();
PopulateTreeview();
}
btnImagesave()
{
SaveImageAfterConvertion();
}
private void NewImageFolderCreation()
{
if (!System.IO.Directory.Exists(fldr))
{
System.IO.Directory.CreateDirectory(fldr);
MessageBox.Show("folder created");
}
else
{
MessageBox.Show("ImageFolder is available populate images into folder");
}
}
private void POpulateTreeview()
{
DirectoryInfo info = new DirectoryInfo(fldr);
TreeNode root = new TreeNode(info.Name);
root.Text = "";
//eng = OcrEngineManager.CreateEngine(OcrEngineType.Professional, false);
//eng.Startup(null, null, null, null);
TreeNode node = new TreeNode();
TrvImageFile.Nodes.Add(root);
FileInfo[] subfileinfo = info.GetFiles("*.*");
if (subfileinfo.Length > 0)
{
for ( j = 0; j < subfileinfo.Length; j++)
{
root.Nodes.Add(subfileinfo[j].Name);
}
}
TrvImageFile.ExpandAll();
}
SaveImageAfterConvertion()
{
if (!System.IO.Directory.Exists(fldr))
{
System.IO.Directory.CreateDirectory(fldr);
doc.Save(ConfigurationSettings.AppSettings["SaveImagefolderPath"] + "\\"+Newtxtfilename+".txt", Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
MessageBox.Show("folder created and image output saved");
}
else
{
doc.Save(ConfigurationSettings.AppSettings["SaveImagefolderPath"] + "\\"+Newtxtfilename+".txt", Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
MessageBox.Show("ImageFolder is available images are Saved into folder Now");
}
}
任何机构都可以在这方面树立榜样.
在我的代码中我想进行修改以接受exe文件的更改.
[edit]已添加代码块,将我的内容作为纯文本..."选项已禁用-OriginalGriff [/edit]
Any Body give good example on this.
where in my code i want to do modifications to accept changes of exe file.
[edit]Code block added, "Treat my content as plain text..." option disabled - OriginalGriff[/edit]
推荐答案
用替换"D:\\SaveImageOutPutFolder"
应用程序配置字符串:
1)在解决方案资源管理器中打开项目属性",然后双击"Settings.settings"
2)在生成的网格中,将名称"更改为"MySetting",并将值"设置为"D:\\ SaveImageOutPutFolder".分别将类型"和范围"保留为字符串"和用户".
3)保存并关闭设置窗口.
4)阅读设置:
Replace the"D:\\SaveImageOutPutFolder"
with a appliciation configuration string:
1) Open your projects Properties in the solution explorer, and double click on "Settings.settings"
2) In the resulting grid, change the Name to "MySetting", and set the Value to "D:\\SaveImageOutPutFolder". Leave Type and Scope as "string" and "User" respectively.
3) Save and close the settings window.
4) To read your setting:
string s = Properties.Settings.Default.MySetting;
5)编写设置:
5) To write your setting:
Properties.Settings.Default.MySetting = "My new setting value";
Properties.Settings.Default.Save();
这篇关于安装后,我们的app.config文件参数值使用c#.net接受更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!