Oh you got the objects wrong, what you wrote was
string path = "C:\\MySqlBackup" + year + "-" + month + "-" + day +
"-" + hour + "-" + minute + "-" + second + "-" + millisecond + ".sql";
StreamWriter file = new StreamWriter(path);
But what you want to do is to create the stream before making the writer, and remember to either escape your escape characters (backslash) or use compiletime constant indicator (@)
string path = @"C:\\MySqlBackup" + year + "-" + month + "-" + day +
"-" + hour + "-" + minute + "-" + second + "-" + millisecond + ".sql";
using (var stream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
{
var writer = new StreamWriter(stream, Encoding.UTF8);
writer.Write("Hello world");
writer.Flush();
writer.Close();
}