2016-08-04 30 views
1

ich auf einem Youtube Downloader arbeite, verwende ich Path.combine aber wenn ich mein Programm starten und eine URL im Feld platzieren habe ich diesen Fehler:Youtube Downloader: ungültige Zeichen in Pfad

illegal characters in path

progressBar.Minimum = 0; 
     progressBar.Maximum = 100; 
     if (!(txturl.Text == string.Empty)) 
     { 
      try 
      { 
       IEnumerable<VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(txturl.Text); 
       VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(cmbResolution.Text)); 
       if (video.RequiresDecryption) 
        DownloadUrlResolver.DecryptDownloadUrl(video); 
       VideoDownloader downloader = new VideoDownloader(video, Path.Combine(Application.StartupPath, video.Title + video.VideoExtension)); 
       downloader.DownloadProgressChanged += downloader_DownloadProgressChanged; 
       Thread thread = new Thread(() => { downloader.Execute(); }) { IsBackground = true }; 
       thread.Start(); 
      } 
      catch (Exception yt) { MessageBox.Show(yt.Message); } 
     } 
     else { MessageBox.Show("Input field cannot be empty."); } 

Antwort

0

Sie muss nicht "\\" hinzufügen, da Path.Combine() sie für Sie einfügt.

EDIT:

Beispiel: Path.Combine(Application.StartupPath, "hello"); kehrt so etwas wie C:\path\to\exe\hello\

+0

Danke, aber nach wie vor die Arbeit verweigern. Bitte kann ich nicht etwas wie "Directory GetCurrentDirectory" verwenden, Bitte beachten Sie meinen Fehler. –

+0

Versuchen Sie dies: 'Path.Combine (Application.StartupPath, string.Format (" {0}. {1} ", video.Title, video.VideoExtension));' –

+0

Ich habe den gesamten Code hier kopiert, bitte helfen Ich überprüfe und debugge es. Danke sir –