private void bteBrowseFile_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Index == 0) { string files = ""; OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Microsoft Excel 2007 (*.xlsx)|*.xlsx|Microsoft Excel 97 - 2003 (*.xls)|*.xls"; ofd.Title = User.UserInfo.LanguageID.Equals("VN") ? "Chọn tệp dữ liệu" : "Choose data file"; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { foreach (string file in ofd.FileNames) { files += file + ";"; } bteBrowseFile.EditValue = files.Equals("") ? string.Empty : files.Substring(0, files.Length - 1); bteBrowseFile.Properties.Buttons[1].Enabled = files.Equals("") ? false : true; } } else if (e.Button.Index == 1) { FileInfo file; foreach (string item in bteBrowseFile.EditValue.ToString().Split(';')) { file = new FileInfo(item.ToString()); if (file.Exists) { if (dtSelectedFile.Select("FilePath='" + item + "'").Length == 0) { dtSelectedFile.Rows.Add(new object[] { file.Name, file.LastWriteTime, Commons.StrFormatByteSize(file.Length), file.FullName, "", false }); } } } wwpStepOne.AllowNext = dtSelectedFile.Rows.Count > 0; } }
private void gridSeletedFiles_DragDrop(object sender, DragEventArgs e) { Cursor saveCursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; FileInfo file; Object data = e.Data.GetData(DataFormats.FileDrop); foreach (object obj in (string[])data) { file = new FileInfo(obj.ToString()); if (file.Exists) { if (dtSelectedFile.Select("FilePath='" + obj + "'").Length == 0) { dtSelectedFile.Rows.Add(new object[] { file.Name, file.LastWriteTime, Commons.StrFormatByteSize(file.Length), file.FullName, "" }); } } } } finally { Cursor.Current = saveCursor; } wwpStepOne.AllowNext = dtSelectedFile.Rows.Count > 0; }
private void AddSelectedFile(string[] files) { FileInfo file; foreach (object item in files) { file = new FileInfo(item.ToString()); if (file.Exists) { if (dtSelectedFile.Select("FilePath='" + item + "'").Length == 0) { dtSelectedFile.Rows.Add(new object[] { file.Name, file.LastWriteTime, Commons.StrFormatByteSize(file.Length), file.FullName, "", false }); } } } }