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. Browsing to a file in forms

Browsing to a file in forms

Scheduled Pinned Locked Moved C#
question
3 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
    naglbitur
    wrote on last edited by
    #1

    Hi there. I am wondering how one goes about doing what is done in email, clicking a button and then you can browse to a file that you want to attach. I want to be able to do this in a windows form app. I dont´know what it is called but when the user presses button he/she can go to a location on the computer and get the path of a file and then something can be done with the file. I wish I could explain better what I mean but I am sure most will know what I am referring to. Thanks F

    L 1 Reply Last reply
    0
    • N naglbitur

      Hi there. I am wondering how one goes about doing what is done in email, clicking a button and then you can browse to a file that you want to attach. I want to be able to do this in a windows form app. I dont´know what it is called but when the user presses button he/she can go to a location on the computer and get the path of a file and then something can be done with the file. I wish I could explain better what I mean but I am sure most will know what I am referring to. Thanks F

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      OpenFileDialog dlg = new OpenFileDialog();
      dlg.Filter = "Text files (*.txt)|*.txt|Bitmaps|*.bmp|All Files|*.*";
      DialogResult res = dlg.ShowDialog();
      if(res == DialogResult.OK)
      {
      Console.WriteLine(dlg.FileName); // here we have our file
      }

      regards :)

      N 1 Reply Last reply
      0
      • L Lost User

        OpenFileDialog dlg = new OpenFileDialog();
        dlg.Filter = "Text files (*.txt)|*.txt|Bitmaps|*.bmp|All Files|*.*";
        DialogResult res = dlg.ShowDialog();
        if(res == DialogResult.OK)
        {
        Console.WriteLine(dlg.FileName); // here we have our file
        }

        regards :)

        N Offline
        N Offline
        naglbitur
        wrote on last edited by
        #3

        Hi, thanks a bunch. It´s so obvious once it has been pointed out;) Thanks again! F

        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