the exe is in the working directory yet the code error saying working directory not…
- User
the exe is in the working directory yet the code error saying working directory not exist but it does
private void videoAsVoiceToolStripMenuItem_Click(object sender, EventArgs e) { TopMost = false; // Prompt user for YouTube URL string videoUrl = Prompt.ShowDialog("Enter YouTube video URL:", "Download YouTube Audio"); if (string.IsNullOrWhiteSpace(videoUrl)) { MessageBox.Show("No URL entered.", "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null) { MessageBox.Show("Please select a dataset and a speaker before downloading audio.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string downloadLocation = Path.Combine( DatasetHome, Dataset_List.SelectedItem.ToString(), Speaker_List.SelectedItem.ToString()); if (!Directory.Exists(downloadLocation)) { try { Directory.CreateDirectory(downloadLocation); } catch (Exception ex) { MessageBox.Show($"Failed to create directory '{downloadLocation}': {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // Prepare output filename template - save as video title with sanitization string outputTemplate = Path.Combine(downloadLocation, "%(title)s.%(ext)s"); try { using (var process = new Process()) { process.StartInfo.FileName = "yt-dlp.exe"; // or "youtube-dl" if you prefer that process.StartInfo.Arguments = $"-x --audio-format wav --output \"{outputTemplate}\" {videoUrl}"; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.CreateNoWindow = true; process.StartInfo.WorkingDirectory = @"C:\AI\yt-dlp\"; process.OutputDataReceived += (s, eArgs) => { if (!string.IsNullOrEmpty(eArgs.Data)) Debug.WriteLine(eArgs.Data); }; process.ErrorDataReceived += (s, eArgs) => { if (!string.IsNullOrEmpty(eArgs.Data)) Debug.WriteLine("ERR: " + eArgs.Data); }; process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); if (process.ExitCode != 0) { MessageBox.Show("Failed to download video audio. See debug output for details.", "Download Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // Reload the voice files in the speaker folder to reflect the new file LoadSpeakers(); MessageBox.Show("Downloaded and converted YouTube audio successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show($"Error while downloading YouTube audio: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } TopMost = true; } - Assistant