Probleme avec StreamWriter
steve87
Messages postés
57
Statut
Membre
-
izidor -
izidor -
Bonjour,
j'ai développé une petite application avec le visual c# 2008 pour enregistrer dans un fichier texte,
et comme j'utilise le StrealWriter il me il crée toujours un fichier texte vide.
voila le code source :
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 WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (save.ShowDialog() == DialogResult.OK)
{
string namefile = save.FileName;
StreamWriter sw = null;
try
{
sw = new StreamWriter(namefile);
sw.WriteLine(t1.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
aider moi svp...
et merci d'avance.
j'ai développé une petite application avec le visual c# 2008 pour enregistrer dans un fichier texte,
et comme j'utilise le StrealWriter il me il crée toujours un fichier texte vide.
voila le code source :
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 WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (save.ShowDialog() == DialogResult.OK)
{
string namefile = save.FileName;
StreamWriter sw = null;
try
{
sw = new StreamWriter(namefile);
sw.WriteLine(t1.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
aider moi svp...
et merci d'avance.