Click here to Skip to main content
16,017,857 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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):

XML
<appsettings>
    <add key="SQLCN" value="Data Source=localhost;Initial Catalog=MyDB;Integrated Security=True" />
    <add key="IMGFOLDER" value="D:\\ImageFolder" />
</appsettings>

C#
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");
            }    
}
Posted
Updated 19-Aug-11 0:10am
v7
Comments
[no name] 19-Aug-11 7:48am    
Do you have a question?

1 solution

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/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900