static void Main(string[] args) { IntPtr handle = GetForegroundWindow(); List <string> selected = new List <string>(); Shell32.Shell shell = new Shell32.Shell(); foreach (var window in shell.Windows()) { var testy = window.HWND; var testy2 = (int)handle; if (window.HWND == (int)handle) { Shell32.FolderItems items = ((Shell32.IShellFolderViewDual2)window.Document).SelectedItems(); foreach (Shell32.FolderItem item in items) { if (args[0] == "browse") { if (item.Path[1] == ':') { String s = String.Format("/select,\"{0}\"", item.Path); shell.ShellExecute("explorer.exe", s); } else { shell.Explore(Path.GetDirectoryName(item.Path)); } } if (args[0] == "open") { shell.ShellExecute(args[1], item.Path); } } } } }
private void btnExplore_Click(object sender, RoutedEventArgs e) { _shell.Explore(_exe_dir); }
/// <summary> /// through Shell Open path. not create new process. /// </summary> /// <param name="vDir">path</param> public static void Explore(string vDir) { var shell = new Shell32.Shell(); shell.Explore(vDir); }
private void Download() { this._link = txtLink.Text; this._start = txtFrom.Text; this._end = txtTo.Text; bool fromToValid = (System.Text.RegularExpressions.Regex.IsMatch(_start, @"^\d+$") || _start.Equals(String.Empty)) && (System.Text.RegularExpressions.Regex.IsMatch(_end, @"^\d+$") || _end.Equals(String.Empty)); if (String.IsNullOrWhiteSpace(_link) && fromToValid) { MessageBox.Show("Error parsing link and/or chapter range!", "", MessageBoxButton.OK, MessageBoxImage.Error); } if (!_link.StartsWith("http")) { _link = @"http://" + _link; } if (Syousetsu.Constants.Site(_link) == Syousetsu.Constants.SiteType.Syousetsu) // syousetsu { if (!_link.EndsWith("/")) { _link += "/"; } } if (!Syousetsu.Methods.IsValidLink(_link)) { MessageBox.Show("Link not valid!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } Syousetsu.Constants sc = new Syousetsu.Constants(_link, _exe_dir, _dl_dir); sc.AddChapter("", ""); // start chapters from 1 HtmlDocument toc = Syousetsu.Methods.GetTableOfContents(_link, sc); if (!Syousetsu.Methods.IsValid(toc, sc)) { MessageBox.Show("Link not valid!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } GetFilenameFormat(); // set up download progress gui-controls Label lb = _controls.Last().Label; lb.Content = Syousetsu.Methods.GetTitle(toc, sc); lb.Background = Brushes.Transparent; lb.ToolTip = "Click to open folder"; ProgressBar pb = _controls.Last().ProgressBar; pb.Maximum = (_end == String.Empty) ? Syousetsu.Methods.GetTotalChapters(toc, sc) : Convert.ToDouble(_end); pb.ToolTip = "Click to stop download"; _start = (_start == String.Empty) ? "1" : _start; _end = pb.Maximum.ToString(); sc.SeriesTitle = lb.Content.ToString(); sc.Link = _link; sc.Start = _start; sc.End = _end; sc.CurrentFileType = _fileType; sc.SeriesCode = Syousetsu.Methods.GetSeriesCode(_link); sc.FilenameFormat = _format; Syousetsu.Methods.GetAllChapterTitles(sc, toc); if (chkList.IsChecked == true) { Syousetsu.Create.GenerateTableOfContents(sc, toc); } System.Threading.CancellationTokenSource ct = Syousetsu.Methods.AddDownloadJob(sc, pb, lb); pb.MouseDown += (snt, evt) => { ct.Cancel(); pb.ToolTip = null; }; lb.MouseDown += (snt, evt) => { _shell.Explore(System.IO.Path.Combine(_dl_dir, sc.SeriesTitle)); }; scrollViewer1.ScrollToLeftEnd(); scrollViewer1.ScrollToBottom(); scrollViewer1.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate); }