1. Select an Excel file
CopyCodeThe 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.