【winform学习】:获取文件路径

OpenFileDialog of1 = new OpenFileDialog();
          
           if (of1.ShowDialog() == DialogResult.OK)
           {
               textBox1.Text = of1.FileName;
           }

FileStream fs1 = new FileStream(textBox1.Text, FileMode.Open, FileAccess.Read);
            StreamReader sw1 = new StreamReader(fs1);
            textBox2.Text = sw1.ReadToEnd();
            sw1.Close();
            fs1.Close();

你可能感兴趣的:(WinForm)