Bonjour
Je crée un fichier texte en cliquant sur un bouton 9, et je lui demande de l'afficher dans un richTextBox en cliquant sur un autre bouton 3, le compilateur me dit:
Le processus ne peut pas accéder au fichier 'C:\Users\Moi\Documents\Visual Studio 2010\Projects\Essai\nom.txt', car il est en cours d'utilisation par un autre processus.
Que faire pour y accéder

voilà le code source


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public void affiche(string s)
        {
            if (File.Exists(s))
            {
                this.richTextBox1.LoadFile(s, RichTextBoxStreamType.PlainText);
                richTextBox1.Show();
            }
 
            else    MessageBox.Show("Aucune information");            
        }
 
 private void button9_Click(object sender, EventArgs e)
        {
            string q="C:\\Users\\Moi\\Documents\\Visual Studio 2010\\Projects\\Essai\\ nom.txt";       
            if (File.Exists(q)) MessageBox.Show("Un fichier porte déja ce nom", "Information");
            else File.Create(q)
        }
 
  private void button3_Click(object sender, EventArgs e)//Informations
        {
            string q="C:\\Users\\Moi\\Documents\\Visual Studio 2010\\Projects\\Essai\\ nom.txt";       
            richTextBox1.Text = q;      
            affiche(q);          
        }