I have written code to open an excel file. I am interested in saving the excel file in temporary folder automatic once the user has indicated which file to open. This is for my application later on to read the excel and do whatever manipulation with it.
Here is my code below:
private void btnbrowseFile_Click(object sender, EventArgs e)
{
openFileDialog1.Title = "Select an Excel file";
openFileDialog1.InitialDirectory = @"c:\";
openFileDialog1.Filter = "Excel 97-2007 WorkBook|*.xls|Excel WorkBook|*.xlsx|All Excel Files|*.xls;*.xlsm;*.xlsx";
openFileDialog1.FilterIndex = 3;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
txtFilename.Text = openFileDialog1.FileName;
}
}
You could do something like this