Adnan
asked on
How do i save file with filename, Date and time. using windows form SaveFileDialog
Hi
I want to create or save files with filename ,date, time....can some one help me with this?
I want to create or save files with filename ,date, time....can some one help me with this?
Stream myStream;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
//saveFileDialog1.Filter = "txt files (*.xml)|*.xml(*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1.Filter = "File Type (*.xml)|*.xml";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
saveFileDialog1.FileName = txtBackupFile.Text;
DateTime currentDateTime = DateTime.Now;
String dateStr = currentDateTime.ToString("yyyy-MM-dd HH_mm_ss");
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((myStream = saveFileDialog1.OpenFile()) != null)
{
// Code to write the stream goes here.
//this.lblBackupPath.Text = "c:\tmp";
txtBackupFilePath.Text = saveFileDialog1.FileName.Substring(dateStr);
myStream.Close();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.