Closed Thread
Results 1 to 6 of 6

Thread: Help me *OpenFileDialog*

  1. #1
    Tuve2 is offline Newbie
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

    Help me *OpenFileDialog*

    I'm trying to make a "OpenFileDialog".
    But I get a 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);
                    }
                }
            }
    Error:
    Code:
    The type or namespace name 'Stream' could not be found (are you missing a using directive or an assembly reference?)
    Can somebody help me?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: Help me *OpenFileDialog*

    Try using the full namespace:

    Code:
    System.IO.Stream myStream = null;

  4. #3
    Tuve2 is offline Newbie
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

    Re: Help me *OpenFileDialog*

    Thanks!

  5. #4
    Tuve2 is offline Newbie
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

    Re: Help me *OpenFileDialog*

    Do you know how I can see the file in a window? now? When I have opened it.

  6. #5
    Jordan Guest

    Re: Help me *OpenFileDialog*

    I'm not sure I understand. You should see all the files in the current directory.

  7. #6
    Tuve2 is offline Newbie
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

    Re: Help me *OpenFileDialog*

    nvm

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. OpenFileDialog
    By Thomas Morgan in forum C# Programming
    Replies: 4
    Last Post: 09-02-2009, 01:22 PM
  2. ..:: using openFileDialog ::..
    By bahrain in forum Visual Basic Programming
    Replies: 10
    Last Post: 03-20-2009, 06:01 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts