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

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -