Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Browse for a file and open the file.

Browse for a file and open the file.

Scheduled Pinned Locked Moved C#
workspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    new2pgrmg
    wrote on last edited by
    #1

    Browse for a file and open the file. It browses fine; but when i open the folders am unable to see the contends.My basic idea is to browse for a file and select the file inside the selected folder. My code is private void btnBrowse_Click(object sender, EventArgs e) { FolderBrowserDialog dialogObj = new FolderBrowserDialog(); dialogObj.RootFolder = Environment.SpecialFolder.MyComputer; if (dialogObj.ShowDialog() == DialogResult.OK) ; { OpenFile(); MessageBox.Show("Hello Jane"); } } public void OpenFile() { OpenFileDialog obj = new OpenFileDialog(); obj.OpenFile(); } } } Am not sure where am going wrong or what has to be done. Thanking You

    C 1 Reply Last reply
    0
    • N new2pgrmg

      Browse for a file and open the file. It browses fine; but when i open the folders am unable to see the contends.My basic idea is to browse for a file and select the file inside the selected folder. My code is private void btnBrowse_Click(object sender, EventArgs e) { FolderBrowserDialog dialogObj = new FolderBrowserDialog(); dialogObj.RootFolder = Environment.SpecialFolder.MyComputer; if (dialogObj.ShowDialog() == DialogResult.OK) ; { OpenFile(); MessageBox.Show("Hello Jane"); } } public void OpenFile() { OpenFileDialog obj = new OpenFileDialog(); obj.OpenFile(); } } } Am not sure where am going wrong or what has to be done. Thanking You

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I recommend you give this up and buy a basic book on C#, so you can start at the beginning. You're obvioulsy guessing what to do here. obj.ShowDialog will show the open file dialog. Then you check the DialogResult to see if the user clicked OK, and then you have a file selected. Even then, obj.OpenFile is not magically going to open the file in your program. You have a ways to go, take a step back and learn some basics.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups