openFileDialog 多檔案設定

openFileDialog1.Title = "File UpLoad";
openFileDialog1.Filter = "圖檔(*.TIF)|*.TIF|" +
                         "圖檔(*.PDF)|*.PDF";                    
openFileDialog1.Multiselect = true;

cntWEB05A["file_name"] = "";
wFileCount = 0;

DialogResult dr = openFileDialog1.ShowDialog();
if (dr == System.Windows.Forms.DialogResult.OK)
{
    foreach (String file in openFileDialog1.FileNames)
    {
        try
        {
            cntWEB05A["file_name"] += file + "\r\n";
            wFileCount++;
        }
        catch (System.Exception ex)
        {
            MessageBox.Show("cmdPath_Click" + ex.Message);
        }
    }
    cntWEB05A["file_name"] = cntWEB05A["file_name"].ToString().Substring(0, cntWEB05AH["file_name"].ToString().Length - 2);
}
lblFileCnt.Text = "上傳合計:" + wFileCount.ToString("0000") + " 筆";
cntWEB05A.Update();

沒有留言: