启用多选的OpenFileDialogue [英] OpenFileDialogue with Multiselction enabaled
本文介绍了启用多选的OpenFileDialogue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在这里有一个问题.
情况是:
我使用OpenFileDialogue选择一些文件(例如TextOne.txt,TextTwo.txt,TextThree.txt).
现在,我要访问将TextTwo.txt发送到要读取的流对象.
该怎么做?
因为;
HI guys,
I have a question here.
The situation is:
I use OpenFileDialogue to select some files (e.g TextOne.txt,TextTwo.txt, TextThree.txt).
Now I want to access send the TextTwo.txt to a stream object to be read.
How to do that?
Because;
stream = OpenFileDialog.OpenFile();
正在获取TextOne.txt.
is getting the TextOne.txt.
FileNames[i]
或
FileName[i]
仅返回字符串,但不返回流.
需要帮助吗?
just returns the string but not the stream.
Need help on this?
推荐答案
OpenFileDialog始终仅返回文件名:它无法返回流,因为它不知道您将要做什么.它:以文本或二进制形式打开.
如果您将其与
一起使用
OpenFileDialog always returns only the file name: It can''t return the stream because it does not know what you are going to do with it: Open it as text or binary.
If you are using it with
this.openFileDialog1.Multiselect = true;
然后,您需要遍历所有名称并自己打开它们:
Then you need to loop through all names and open them yourself:
foreach (String file in openFileDialog1.FileNames)
{
FileStream fileStream = new FileStream(file, FileMode.Open);
... // Do something with the stream.
}
这篇关于启用多选的OpenFileDialogue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文