私は実際にコーディングしたことがありません。それは勉強したことがなく、似たようなもので、自分で学習したことはありませんでした。 しかし、私は2日間問題を抱えています。理解できない部分がありますので、私が助けてくれることを願っています。メソッドから文字列を取得できません
youtubedlCurrentWorker_Process()が作成される前に、私は 'public string CurrentYouTubeDLVersion'を定義しました。
アプリケーションのボタンでyoutubedlCompareVersion_Process()を実行すると、比較ポイントになるとCurrentYouTubeDLVersion文字列が空になります。
以下は私のコードの一部です。
GetCurrentVersionがその前に実行されていたのに、なぜCurrentVideoでCurrentYouTubeDLVersion文字列が空であるのですか?
Visual Studioで "CurrentYouTubeDLVersion"をダブルクリックしても、GetCurrentVersion_Processのリンクにはリンクが表示されません。 youtubedlGetCurrentVersion_Process
メソッド内
namespace MediaDownloader
{
public partial class updates : UserControl
{
public string LatestYoutubeDLVersion;
public string CurrentYouTubeDLVersion;
public void youtubedlGetCurrentVersion_Process()
{
if (File.Exists(YouTubeDLPath))
{
//Here I get the current version of youtube-dl.exe, to get the version number, we have to run youtube-dl.exe --version
Process youtubedl = new Process();
youtubedl.StartInfo.CreateNoWindow = true;
youtubedl.StartInfo.UseShellExecute = false;
youtubedl.StartInfo.RedirectStandardOutput = true;
youtubedl.StartInfo.RedirectStandardError = true;
youtubedl.StartInfo.FileName = YouTubeDLPath;
youtubedl.StartInfo.Arguments = " --version";
youtubedl.Start();
string CurrentYouTubeDLVersion = youtubedl.StandardOutput.ReadToEnd();
this.Dispatcher.Invoke((Action)(() =>
{
CurrentYouTubeDLVersionText.Text = "Current youtube-dl.exe version: " + CurrentYouTubeDLVersion;
YouTubeDLVersionStatusText.Text = null;
UpdateYouTubeDL.IsEnabled = false;
}));
}
public void youtubedlCompareVersion_Process()
{
youtubedlGetCurrentVersion_Process();
string LatestYoutubeDLVersion = WebClient.DownloadString("https://yt-dl.org/latest/version");
MessageBox.Show("Latest:" + LatestYoutubeDLVersion + "Current " + CurrentYouTubeDLVersion);
int YouTubeDLUptodate = CurrentYouTubeDLVersion.CompareTo(LatestYoutubeDLVersion);
if (YouTubeDLUptodate < 1)
{
YouTubeDLVersionStatusText.Text = "Your youtube-dl.exe is out of date, please click the button below to update.";
UpdateYouTubeDL.IsEnabled = true;
}
else
{
YouTubeDLVersionStatusText.Text = "youtube-dl.exe is up to date!";
UpdateYouTubeDL.IsEnabled = false;
}
}
}
を動作するはずですし、それがすべてでは全く接続されていません' public CurrentYouTubeDLVersion'をクラスの先頭に追加しました。 –
グラントウィニーが正しいです。メソッドで 'LatestYoutubeDLVersion'と' CurrentYouTubeDLVersion'の前に 'string'を削除してください。 –