Ahsan Ali

Ahsan Ali

  • NA
  • 1
  • 671

Save File Error

Oct 20 2015 2:01 AM
I'm having the following error while trying to save a text file
Empty Path is Not Legal
I'm really confused about that
Thanks in advance .. :)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace Filing
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button_Save_Click(object sender, EventArgs e)
{

SaveFileDialog file = new SaveFileDialog();

file.Filter = "Text (*.txt) | Word File *.doc";
file.Title = "Save a file";
// string FileName = file.FileName;
File.WriteAllText(file.FileName, richTextBox1.Text);


file.ShowDialog();

}

private void button_exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

 


Answers (1)