I'm trying to make a "OpenFileDialog".
But I get a error.
Error:Code:private void button1_Click(object sender, EventArgs e) { Stream myStream = null; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\"; openFileDialog1.Filter = "txt files (*.txt)|*.txt|bat files (*.bat)|*.bat|All files (*.*)|*.*"; openFileDialog1.FilterIndex = 2; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { if ((myStream = openFileDialog1.OpenFile()) != null) { using (myStream) { // Insert code to read the stream here. } } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }
Can somebody help me?Code:The type or namespace name 'Stream' could not be found (are you missing a using directive or an assembly reference?)
Try using the full namespace:
Code:System.IO.Stream myStream = null;
Thanks!![]()
Do you know how I can see the file in a window? now? When I have opened it.
I'm not sure I understand. You should see all the files in the current directory.
nvm
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks