Kodlama konusunda gerçekten yeniyim, hiç çalışmadım ya da benzer bir şey, sadece kendim öğreniyorum, daha önce hiç yapmadım, ancak ilk gerçek uygulamanızı yeni oluşturmaya çalışıyorum. Ancak, 2 gün boyunca anlayamadığım bazı problemlerim var, bu yüzden bana yardımcı olabileceğinizi umuyorum.Bir yöntemden bir dize alınamadı
Tamam, youtubedlCurrentWorker_Process() oluşturulmadan önce, 'public String CurrentYouTubeDLVersion' tanımladım.
Uygulamamdaki bir düğme youtubedlCompareVersion_Process() öğesini çalıştırdığında, CurrentYouTubeDLVersion dizesi, karşılaştırma noktasına geldiğinde boştur.
Aşağıda kodumun sadece bir kısmı yer almaktadır.
GetCurrentVersion daha önce kaçtı iken, CurrentVisualDVersion boşluğu CompareVersion'da neden boş?
Visual Studio'da "CurrentYouTubeDLVersion" ı tıklatsam bile, GetCurrentVersion_Process içindeki bir bağlantıyı göstermez. youtubedlGetCurrentVersion_Process
yöntemle İçinde
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;
}
}
}
çalışmalıdır ve bu hiç de kesinlikle hiçbir bağlantısı yoktur' public CurrentYouTubeDLVersion' sınıfın en üstüne eklediniz. –
Grant Winney haklı. Yöntemlerinizde 'String' 'LatestYoutubeDLVersion' ve' CurrentYouTubeDLVersion' önce kaldırın. –