1. Select Excel type File
Copy Code code 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 file name
}
Else
{
Action when file is not selected
}
2. Use DOS command to copy files in batches
function: filename unchanged, suffix name change (changed from *.BGF to *.xls)
Create file Test.bat, content: Copy *BGF \new\*.xls
New file folder for storage, and *BGF the same directory code as: Copy *BGF \new\*.xls, the next level of directory code: Copy *BGF New\*.xls, do not slash,
(1) Run-CMD-CD F:
(2) CD file name *
(3) Executive Test.bat