1. Select an excel file
Copy codeThe Code is as follows:
OpenFileDialog fileDialog = new OpenFileDialog ();
// FileDialog. InitialDirectory = "d :\\";
FileDialog. Title = "select file ";
// FileDialog. Filter = "xml files (*. xml) | *. xml ";
FileDialog. Filter = "Excel file | *. xls | all files | *.*";
FileDialog. FilterIndex = 1;
FileDialog. RestoreDirectory = true;
If (fileDialog. ShowDialog () = DialogResult. OK)
{
String fileName = fileDialog. FileName;
// Use the file name
}
Else
{
// Operation when no file is selected
}
2. Copy files in batches using the DOS command
Function: the file name remains unchanged, and the suffix is changed (from *. bgf to *. xls)
Create the file test. bat. Content: copy * bgf \ new \ *. xls
New is the folder for storing new files. The code in the same directory as * bgf is copy * bgf \ new \*. xls. The code for the next-level directory is copy * bgf new \*. xls, do not slash,
(1) Run-cmd-cd f:
(2) cd file name *
(3) execute test. bat.