我尝试下载文件并能够选择其位置enter image description here
这是我编写的代码
在“使用目录”中,这是我定义目录的位置,但是我希望能够通过“ FolderbrowserDialog”进行选择
答案 0 :(得分:0)
特别是:
if(result == DialogResult.OK)
{
openFileName = openFileDialog1.FileName;
try
{
// Output the requested file in richTextBox1.
Stream s = openFileDialog1.OpenFile();
richTextBox1.LoadFile(s, RichTextBoxStreamType.RichText);
s.Close();
fileOpened = true;
}
catch(Exception exp)
{
MessageBox.Show("An error occurred while attempting to load the file. The error is:"
+ System.Environment.NewLine + exp.ToString() + System.Environment.NewLine);
fileOpened = false;
}