0
You know that basic difference between salvage and the save as of the text editors? So, I’m wanting to put in my application only the option "save", however, after searching a lot on the net only figure out the way save as that involves the use of Openfiledialog, I wanted to know how to put in my save an option where it saves the change in the text without opening Openfiledialog.
That was the best you could do using Open:
SaveFileDialog sfd = new SaveFileDialog();
sfd.InitialDirectory = @"C:\";
sfd.RestoreDirectory = true;
sfd.FileName = "*.txt";
sfd.DefaultExt = "txt";
sfd.Filter = "txt files (*.txt) | *.txt";
if(sfd.ShowDialog() == DialogResult.OK)
{
Stream fileStream = sfd.OpenFile();
StreamWriter sw = new StreamWriter(fileStream);
sw.Write(JanelaDeTxt.Text);
sw.Close();
fileStream.Close();
}
For that, you already have to know the path from where you will be saved, right? If not, where will it save? In this case, just pass the path to save as argument to
StreamWriter
– Kevin Kouketsu