Recommendations: When you write a program try to name components with a logic name, example txtUri, txtFolderName, btnDownload, this facilitates understanding.
If you have a File Name and Dynamic Folder it's possible.
public void indirButon_Click(object sender, EventArgs e)
{
string fileName = GetFileName("webcams.mp4");
WebClient web = new WebClient();
web.DownloadFileCompleted += new AsyncCompletedEventHandler(DosyaIndirme);
Uri DosyaAdresi = new Uri(label3.Text);
web.DownloadFile(DosyaAdresi, fileName);
}
This method Get File Name with new Dynamicly Folder.
private static string GetFileName(string fileName)
{
string klasor = textBox1.Text;
string directoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Hilal Beyzasource", klasor);
if (!Directory.Exists(directoryPath))
Directory.CreateDirectory(directoryPath);
return Path.Combine(directoryPath, fileName);
}
If User pass complete path you need remove adapt the directoryPath
string directoryPath = Path.Combine(textBox1.Text);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…