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) { var files = (from item in fileList where item.FilePath.ToLower().Equals(file.FullName.ToLower()) select item).ToList(); if (files != null && files.Count > 0) { continue; } fileList.Add(new SelectedFile { FileName = file.Name, DateModified = file.LastWriteTime, FileSize = CommonEngine.StrFormatByteSize(file.Length), FilePath = file.FullName, IsValid = false }); } } } catch (Exception ex) { CommonEngine.ShowExceptionMessage(ex); } finally { Cursor.Current = saveCursor; } grvSeletedFiles.RefreshData(); wwpStepOne.AllowNext = btnCheckValid.Enabled = fileList.Count > 0; }
private void btnBrowseFile_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Index == 0) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Microsoft Excel 97 - 2003 (*.xls)|*.xls|Microsoft Excel 2007 (*.xlsx)|*.xlsx"; ofd.Title = ConfigEngine.Language.Equals("vi") ? "Chọn tệp dữ liệu" : "Choose data file"; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { foreach (string file in ofd.FileNames) { var _file = new FileInfo(file); if (_file.Exists) { var files = (from item in fileList where item.FilePath.ToLower().Equals(_file.FullName.ToLower()) select item).ToList(); if (files != null && files.Count > 0) { continue; } fileList.Add(new SelectedFile { FileName = _file.Name, DateModified = _file.LastWriteTime, FileSize = CommonEngine.StrFormatByteSize(_file.Length), FilePath = _file.FullName, IsValid = false }); } } grvSeletedFiles.RefreshData(); wwpStepOne.AllowNext = btnCheckValid.Enabled = string.IsNullOrEmpty(ofd.FileNames.ToString()) ? false : true; } } }