安装后,我们的app.config文件参数值接受用户使用c#.net选择的更改 [英] After instalation our app.config file parameter value accepting changes by user choice using c#.net

查看:64
本文介绍了安装后,我们的app.config文件参数值接受用户使用c#.net选择的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装后,我们的app.config文件参数值使用c#.net接受更改
查看更多:C#hello
我正在开发win应用程序,用于从系统位置检索图像并将其转换为文本文件并保存到系统位置,这是我的工作.我要在安装后接受app.config文件的更改.在此,用户修改app.config文件的参数值(此处是用户选择的驱动器地址),这意味着在不进行编译的情况下,exe会接受该远程系统中的更改.示例iam在一个系统中创建了一个winapp设置文件和部署对象.
之后,他在那时更改了app.config文件参数(此文件包含系统驱动器位置),我的应用程序接受该驱动器地址并执行iamge进程.

我对系统中的固定位置有一个想法.但是我想在安装后接受用户的选择.我的代码是(这是从总代码中得到的平安):

After instalation our app.config file parameter value accepting changes using c#.net
See more: C# hello
I am 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 thatis user choice) ,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. But I want to accept user choice at after instalation. 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" />
</appsettings>


private void SaveToIsolatedStorage(XDocument document, string file)
{
    // Open the stream from IsolatedStorage.
    IsolatedStorageFileStream stream = new IsolatedStorageFileStream(
        file, FileMode.Create, GetUserStore());
    using (stream)
    {
        using (StreamWriter writer = new StreamWriter(stream))
        {
            document.Save(writer);
        }
    }
}

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");
            }    
}

推荐答案

如果要更改或编辑app.config文件,请参见以下示例.


http://chiragrdarji.wordpress.com /2008/09/25/how-to-change-appconfig-file-run-time-using-c/ [
If you want to change or edit your app.config file, here is an example...


http://chiragrdarji.wordpress.com/2008/09/25/how-to-change-appconfig-file-run-time-using-c/[^]


这篇关于安装后,我们的app.config文件参数值接受用户使用c#.net选择的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆