public static void ExportTables(IEnumerable<string> selectedTables, string exportMethod, string separator, ProgressWindow progress) { var t = new DirectoryBrowser(); if (!string.IsNullOrEmpty(_selectedPath)) t.SelectedPath = _selectedPath; t.Show(); if (t.DialogResult != DialogResult.OK) return; _selectedPath = t.SelectedPath; Logger.LogInfo("Exporting data to directory: {0}", _selectedPath); var dbPath = DBUtilities.DbPath; foreach (var selectedTable in selectedTables) { if (progress.Worker.CancellationPending) { progress.Args.Cancel = true; return; } var startInfo = new ProcessStartInfo { FileName = "SqlCeCmd40.exe", WorkingDirectory = Directory.GetCurrentDirectory() + "\\tools", CreateNoWindow = true, UseShellExecute = true, WindowStyle = ProcessWindowStyle.Hidden, }; if (exportMethod == "CSV") //export CSV { var outputFile = string.Format("{0}\\{1}.csv", _selectedPath, selectedTable); startInfo.Arguments = string.Format( "-d \"Data Source={0}\" -q \"SELECT * FROM {1}\" -o \"{2}\" -h {3} -s \"{4}\" -W", dbPath, selectedTable, outputFile, Int32.MaxValue, separator); } else //export XML { var outputFile = string.Format("{0}\\{1}.xml", _selectedPath, selectedTable); startInfo.Arguments = string.Format( "-d \"Data Source={0}\" -q \"SELECT * FROM {1}\" -o \"{2}\" -x", dbPath, selectedTable, outputFile); } using (var process = Process.Start(startInfo)) { process.WaitForExit(); } ++progress.Current; progress.InvokeUpdate(selectedTables.Count(), string.Format("Exporting table '{0}'", selectedTable)); } }