The problem is not correctly recognized. You really want to save a file, not to press any button, which would be a typical abuse of technology. If you need to save some data in a file without user intervention do a simple thing — forget about using any dialog box at all.
Now, a dialog box has nothing to do with file/stream I/O, it only provides a file name. Instead, you need to come up some schema with auto-generated file names.
I would suggest to a name a file by the system time. Something like that:
System.DateTime time = System.DateTime.Now;
string time = time.ToString("s").Replace(':', '-');
string fileName = string.Format("{0}.xls", time);
It will give you a file name unique with 1-sec resolution.
See
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[
^].
If some file come more frequently, you can use system ticks (100-ns intervals, frequent enough for any practical purpose:
System.DateTime time = System.DateTime.Now;
string fileName = string.Format("{0:X16}.xls", time.Ticks);
—SA