I'm working on a simple tool that loads a text file and does several regex search and replaces when hitting a button. This all works without problem. I have a textbox to preview the text after f&r and it all looks solid in there.
However, when i save my file as .txt and then open it suddenly begins with these characters æ- (those are the very first characters in the entire file and the only ones I don't want).
I thought it may be an encoding error as I'm pretty positive that it's not the sideproduct of 1 of the replaces.
I've tried searching for people with a similar issue but couldn't find an answer. I'm very new to C#, normally I do this stuff in Notepad++ but I wanted to try building a simple tool around a Notepad++ macro.
SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "Save file";
sfd.Filter = "TXT files|*.txt";
sfd.InitialDirectory = @"C:\temp";
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string path = sfd.FileName;
BinaryWriter bw = new BinaryWriter(File.Create(path));
bw.Write(textBox1.Text);
bw.Dispose();
}
Does it have anything with the saving of the file itself? Forgive me if this is some kind of rookie mistake. Any help is appreciated. Thanks.