Effacer fichier.txt existant
Fermé
tipi75
Messages postés
680
Date d'inscription
lundi 20 août 2007
Statut
Membre
Dernière intervention
16 avril 2015
-
14 déc. 2008 à 19:04
halo_quebec Messages postés 161 Date d'inscription samedi 14 avril 2007 Statut Membre Dernière intervention 9 juin 2010 - 14 déc. 2008 à 20:50
halo_quebec Messages postés 161 Date d'inscription samedi 14 avril 2007 Statut Membre Dernière intervention 9 juin 2010 - 14 déc. 2008 à 20:50
A voir également:
- Effacer fichier.txt existant
- Impossible d'afficher le rapport de tableau croisé dynamique sur un rapport existant ✓ - Forum Excel
- Effacer tout l'historique - Guide
- Effacer les cookies - Guide
- Comment effacer une page sur word - Guide
- Touche effacer ne fonctionne plus ✓ - Forum Clavier
5 réponses
halo_quebec
Messages postés
161
Date d'inscription
samedi 14 avril 2007
Statut
Membre
Dernière intervention
9 juin 2010
10
14 déc. 2008 à 20:10
14 déc. 2008 à 20:10
if(File.Exists(string path))
tipi75
Messages postés
680
Date d'inscription
lundi 20 août 2007
Statut
Membre
Dernière intervention
16 avril 2015
26
14 déc. 2008 à 20:13
14 déc. 2008 à 20:13
merci, ça j'ai fais. Mais je voudrais faire la suite en vérifiant tous les fichiers qui sont dans le répertoire fichiers. Puis si le fichier.txt existe déjà je voudrais le supprimer et garder le nouveau.
Merci pour ton aide.
Merci pour ton aide.
halo_quebec
Messages postés
161
Date d'inscription
samedi 14 avril 2007
Statut
Membre
Dernière intervention
9 juin 2010
10
14 déc. 2008 à 20:22
14 déc. 2008 à 20:22
ta juste a faire la commande normal... il va reecrire pardessu
tipi75
Messages postés
680
Date d'inscription
lundi 20 août 2007
Statut
Membre
Dernière intervention
16 avril 2015
26
14 déc. 2008 à 20:40
14 déc. 2008 à 20:40
c'est à dire???, moi je voudrais effacer mon ancien fichier et le remplacer par le nouveau.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
halo_quebec
Messages postés
161
Date d'inscription
samedi 14 avril 2007
Statut
Membre
Dernière intervention
9 juin 2010
10
14 déc. 2008 à 20:50
14 déc. 2008 à 20:50
ok...
voici un example de code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private int[] tabint;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
tabint = new int[] { 0, 346, 234, 23, 6, 34, 6, 3, 345 };
StreamWriter writer = new StreamWriter("mr.txt");
foreach (int chiffre in tabint)
{
writer.WriteLine(chiffre);
}
writer.Close();
}
private void button2_Click(object sender, EventArgs e)
{
tabint = new int[] { 2, 346, 234, 23, 6, 34, 6, 3, 345 };
StreamWriter writer = new StreamWriter("mr.txt");
foreach (int chiffre in tabint)
{
writer.WriteLine(chiffre);
}
writer.Close();
}
}
}
Quand je clique sur mon bouton1,
dans mr.txt il va avoir ca 0, 346, 234, 23, 6, 34, 6, 3, 345 d'ecrit 1 par dessu lautre sans virgule;
lorsque je vais cliquer sur mon bouton 2,
dans mr.txt il va avoir ca 2, 346, 234, 23, 6, 34, 6, 3, 345 d'ecrit 1 par dessu lautre sans virgule;
meme si le fichier existe deja...
Loorsque j'ecrit quelque chose sur un fichier deja existant, par default, il reecrit pardessu...
voici un example de code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private int[] tabint;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
tabint = new int[] { 0, 346, 234, 23, 6, 34, 6, 3, 345 };
StreamWriter writer = new StreamWriter("mr.txt");
foreach (int chiffre in tabint)
{
writer.WriteLine(chiffre);
}
writer.Close();
}
private void button2_Click(object sender, EventArgs e)
{
tabint = new int[] { 2, 346, 234, 23, 6, 34, 6, 3, 345 };
StreamWriter writer = new StreamWriter("mr.txt");
foreach (int chiffre in tabint)
{
writer.WriteLine(chiffre);
}
writer.Close();
}
}
}
Quand je clique sur mon bouton1,
dans mr.txt il va avoir ca 0, 346, 234, 23, 6, 34, 6, 3, 345 d'ecrit 1 par dessu lautre sans virgule;
lorsque je vais cliquer sur mon bouton 2,
dans mr.txt il va avoir ca 2, 346, 234, 23, 6, 34, 6, 3, 345 d'ecrit 1 par dessu lautre sans virgule;
meme si le fichier existe deja...
Loorsque j'ecrit quelque chose sur un fichier deja existant, par default, il reecrit pardessu...