Hello,
i'm new in the programming world and i try to create a small program who can modify a simple ini file with different ligne i need to change with textbox.
The problem is i use an openfiledialog. I can open and use the file but after i need to modify that file but it's seems that the openfiledialog lock the file and i can't modify anything in that file !
public partial class Form1 : Form
{
List<string> site = new List<string>();
List<string> Read_fileTAB = new List<string>();
string section = "";
string Garg1 = "";
string Garg2 = "";
string Garg3 = "";
string Garg4 = "";
string link_Read1 = "";
string chemin_fichier1 = "";
string nom_fichier1 = "";
int arg1_pos = 0;
int arg2_pos = 0;
int arg3_pos = 0;
int arg4_pos = 0;
public Form1()
{
InitializeComponent();
}
private void ouvrirToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "Fichier de configuration FTP INI (*.ini)|*.ini|All files (*.*)|*.*";
openFileDialog1.RestoreDirectory = false;
openFileDialog1.ShowHelp = true;
openFileDialog1.ShowReadOnly = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if (openFileDialog1.OpenFile() != null)
{
//MessageBox.Show("Fichier ouvert correctement");
chemin_fichier1 = openFileDialog1.FileName;
//new FileStream(chemin_fichier1, FileMode.Open, FileAccess.ReadWrite);
Read_file(chemin_fichier1,"[FTP-SETTINGS]", "Site", "port", "login", "password");
openFileDialog1.Dispose();
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
}
Thank you for your reply