Windowsフォームを読み込んで、何らかの条件に基づいてラベルの値を変更します。しかし、フォームを実行すると、完全なロジックが実行され、フォームがロードされます。最後の条件に挿入されたラベル値が表示されます。c#Winforms UIを表示するだけでなくコードを実行します
フォームがロードされ、ロジックが実行されるときにラベル値が動的に変更される必要があります。私を案内してください。おかげ
bool filesPresent = false;
string contentPath = "C:\\folder\\";
string downloadUrl = "http://a.com/file.rar";
public Loading()
{
InitializeComponent();
Shown += Loading_Shown;
}
private void Loading_Shown(object sender, EventArgs e)
{
label1.text = "Checking Files..."
if (File.Exists(contentPath))
{
if (File.Exists(contentPath + "config.xml"))
{
int fCount = Directory.GetFiles(contentPath, "*", SearchOption.TopDirectoryOnly).Length;
if (fCount >= 5)
{
filesPresent = true;
}
else filesPresent = false;
}
else filesPresent = false;
}
else filesPresent = false;
if (filesPresent == false)
{
label1.text = "Downloading Files..."
Directory.CreateDirectory(contentPath);
using (var client = new WebClient())
{
client.DownloadFile(downloadUrl, contentPath + "aplus1.rar");
}
}
}
private void Loading_Load(object sender, EventArgs e)
{
}
'WebClient.DownloadFileAsync()'例えば:http://stackoverflow.com/questions/4172158/progress-bar-and-webclient –
こんにちは、再び要件をチェックしてください。 –
どのようなロジックですか?コードを表示するか、誰もあなたを助けることはできません。 – DonBoitnott