/// <summary> /// make sure we have a good place and desire to write the file /// </summary> /// <param name="goodlines"></param> /// <param name="s"></param> private void WriteGoodFile(IEnumerable <string> goodlines, stFileNames s, double div) { string dest; string filename; string fullpath; dest = Path.Combine(rootFolder, "source_data"); //check is source_data folder exists and make it if it doesn't if (!Directory.Exists(dest)) { Directory.CreateDirectory(dest); } filename = Path.GetFileName(s.Text); fullpath = Path.Combine(dest, filename); //check if file exists and ask to replace if it does if (File.Exists(fullpath)) { if (MessageBox.Show("File exists, would you like to replace it?\n\n" + filename, "File Exists", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { return; } } curProgressText = "Importing " + filename; WriteGoodLines(fullpath, s.Text, goodlines, div); }
internal void fnDropFiles(DragEventArgs e) { if (tempListOfFiles == null) { tempListOfFiles = new ObservableCollection <stFileNames>(); } string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { if (File.Exists(file)) { if (file.EndsWith(".gdt")) { if (ListOfFiles != null) { var alreadyincluded = ListOfFiles.Where(x => x.Text == file); if (alreadyincluded.Count() > 0) { continue; } } else { ListOfFiles = new ObservableCollection <stFileNames>(); } stFileNames st = new stFileNames(); st.Text = file; ListOfFiles.Add(st); } } } if (ListOfFiles.Count > 0) { SeeClear = Visibility.Visible; } else { SeeClear = Visibility.Collapsed; } if (rootFolder != null) { ImportGDT = Directory.Exists(rootFolder) && ListOfFiles.Count > 0; return; } ImportGDT = false; }