C# WinForm OpenFileDialog设置

在Form中拉入一个OpenFileDialog

        private void button4_Click(object sender, System.EventArgs e) //Select tracker file button
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.InitialDirectory = @"C:\Users\LILYHU1\Desktop\";
            ofd.RestoreDirectory = true;
            if (ofd.ShowDialog()==DialogResult.OK)
            {
                textBox3.Text = ofd.FileName;
            }
        }

在Form中拉入folderBrowserDialog:

FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
	textBox2.Text = fbd.SelectedPath;
}

你可能感兴趣的:(C#,c#,开发语言,.net)