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