private void Link() { if (Path.GetPathRoot(this._outputBaseFolder) != Path.GetPathRoot(this._sourceFolder)) { this.UpdateStatusFormat( "Link failed, the output basefolder and the source folder must be in the same driver!"); return; } if (this._unlocatedCount != 0) { MessageBoxResult result = MessageBox.Show(this._unlocatedCount + " files unlocated, hard link anyway?", "Confirm", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel); if (result != MessageBoxResult.OK) { return; } } this.UpdateStatusFormat("Linking..."); var helper = new HardLinkHelper(); helper.HardLink(this._locateResult.TorrentFileLinks, this._copyLimitSize, this._outputName, this._outputBaseFolder); // copy .torrent file string targetTorrentFile = Path.Combine(Path.Combine(this._outputBaseFolder, this._outputName), Path.GetFileName(_torrentFile)); helper.Copy(_torrentFile, targetTorrentFile); this.UpdateStatusFormat("Done."); Process.Start("explorer.exe", Path.Combine(this._outputBaseFolder, this._outputName)); }
public void InitCommands() { this._selectSourceFolderCommand = new RelayCommand(() => { var dialog = new VistaFolderBrowserDialog(); dialog.ShowNewFolderButton = true; dialog.ShowDialog(); if (!string.IsNullOrWhiteSpace(dialog.SelectedPath)) { this.Set(() => this.SourceFolder, ref this._sourceFolder, dialog.SelectedPath); this.Set(() => this.ParentFolder, ref this._parentFolder, Directory.GetParent(dialog.SelectedPath).FullName); this.Set(() => this.FolderName, ref this._folderName, Path.GetFileName(dialog.SelectedPath) + "_Copy"); } }); this._selectParentFolderCommand = new RelayCommand(() => { var dialog = new VistaFolderBrowserDialog(); dialog.ShowNewFolderButton = true; dialog.ShowDialog(); if (dialog.SelectedPath != null) { this.Set(() => this.ParentFolder, ref this._parentFolder, dialog.SelectedPath); } }); this._defaultCommand = new RelayCommand(() => { if (string.IsNullOrWhiteSpace(this._sourceFolder)) { this.Set(() => this.FolderName, ref this._folderName, ""); } else { this.Set(() => this.FolderName, ref this._folderName, Path.GetDirectoryName(_folderName) + "_HLinked"); } }); this._linkCommand = new RelayCommand(() => { var helper = new HardLinkHelper(); helper.HardLink(this._sourceFolder, this._parentFolder, this._folderName, 1024000); Process.Start("explorer.exe", Path.Combine(this._parentFolder, this._folderName)); }, () => !string.IsNullOrWhiteSpace(this._sourceFolder) && !string.IsNullOrWhiteSpace(this._parentFolder) && !string.IsNullOrWhiteSpace(this._folderName)); }