Un petit probleme dans un long code
Bonjour, en faite j'ai un petit souci que visual c# m'indique. Voici le code (assez long):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace N49_Writing_Text
{
public partial class Fenetre_principal : Form
{
public Fenetre_principal()
{
InitializeComponent();
}
private void Quitter_Click(object sender, EventArgs e)
{
Environment.Exit(0);
}
private void Enregistrer_sous_Click_1(object sender, EventArgs e)
{
Enregistrer_fichier.InitialDirectory = Application.ExecutablePath;
Enregistrer_fichier.Filter = "Document N49 Writing Text (*.texte)|*.texte";
Enregistrer_fichier.FilterIndex = 0;
if (Enregistrer_fichier.ShowDialog() == DialogResult.OK)
{
string nomFichier = Enregistrer_fichier.FileName;
StreamWriter fichier = null;
try
{
fichier = new StreamWriter(nomFichier);
fichier.Write(Zone_de_saisie.Text);
}
catch (Exception ex)
{
MessageBox.Show("Problème à l'écriture du fichier (" + ex.Message + ")", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
finally
{
if (fichier != null)
{
fichier.Dispose();
}
}
}
}
private void Ouvrir_Click(object sender, EventArgs e)
{
Ouvrir_fichier.InitialDirectory = Application.ExecutablePath;
Ouvrir_fichier.Filter = "Document N49 Writing Text (*.texte)|*.texte|Document Microsoft Bloc-notes (*.txt*)|*.txt";
Ouvrir_fichier.FilterIndex = 0;
if (Ouvrir_fichier.ShowDialog() == DialogResult.OK)
{
string nomFichier = Ouvrir_fichier.FileName;
StreamWriter fichier = null;
try
{
fichier = new StreamWriter(nomFichier);
Zone_de_saisie.Text = fichier.ReadToEnd();
}
catch (Exception ex)
{
MessageBox.Show("Problème à la lecture du fichier (" + ex.Message + ")", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
finally
{
if (fichier != null)
{
fichier.Dispose();
}
}
}
}
}
} |
Le probleme vient du code en rouge mais je ne vois vraiment pas d'ou viens ce probleme. Si quelqu'un peut me debloquer, je le remerci.