winforms - Save excel file in a temporary folder in c# -


I have written code to open the Excel file I I'm interested in saving Excel file into a temporary folder by automatic once the user Has indicated what file to open. This later reads Excel for my application and manages to manipulate it with it. Here's the bottom of my code:

  private void btnbrowseFile_Click (object sender, EventArgs e) {openFileDialog1.Title = "Select the 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 can do something like this

 < code> if (openFileDialog1.ShowDialog () == DialogResult.OK) {File.Copy (openFileDialog1.FileName, Path.Combine (Path.GetTempPath (), Path.GetFileName (openFileDialog1.FileName)), true); }    

Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -