天天看點

Winform中上傳、下載下傳檔案選擇打開檔案的位置

  1. 打開将要上傳的檔案
var fileName="";
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Multiselect = true;
fileDialog.Title = "請選擇檔案";
fileDialog.Filter = "Excel檔案 (*.xls;*.xlsx)|*.xls;*.xlsx|所有檔案 (*.*)|*.*";
if (fileDialog.ShowDialog() == DialogResult.OK)
{
   fileNames = fileDialog.FileNames;//擷取所有将上傳檔案的全路徑數組集合
}      

  

  2.下載下傳檔案時選擇儲存的位置

string selePath = "";
FolderBrowserDialog frmBrowser = new FolderBrowserDialog();
if (frmBrowser.ShowDialog() == DialogResult.OK)
{
   selePath = frmBrowser.SelectedPath;
}      

繼續閱讀