设置IE浏览器的默认下载路径

时间:2024-06-19 23:05:02

实现效果:

  设置IE浏览器的默认下载路径

知识运用:

  Default Download Directory键

实现代码:

        private void button2_Click(object sender, EventArgs e)
{
try
{
RegistryKey regMain = Registry.CurrentUser;
RegistryKey regChild = regMain.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main");
regChild.SetValue("Default Download Directory", textBox1.Text, RegistryValueKind.String);
MessageBox.Show("设置默认下载路径成功");
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
}