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. FileStream help! :(

FileStream help! :(

Scheduled Pinned Locked Moved C#
help
6 Posts 4 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.
  • M Offline
    M Offline
    moonboy
    wrote on last edited by
    #1

    Hi, im trying to get a image from a path. foto is a string path espec. by the user. FileStream f = new FileStream( foto, FileMode.Open ); Image img = Image.FromStream( f ); This doesnt working, its only works if the image is in the same folder of the program =/ Thanks.

    P 1 Reply Last reply
    0
    • M moonboy

      Hi, im trying to get a image from a path. foto is a string path espec. by the user. FileStream f = new FileStream( foto, FileMode.Open ); Image img = Image.FromStream( f ); This doesnt working, its only works if the image is in the same folder of the program =/ Thanks.

      P Offline
      P Offline
      Peter Nirschl
      wrote on last edited by
      #2

      MoOnBoY wrote: Image.FromStream( f ); I think there is a better way! Just use: Image img = Image.FromFile("C:\\..."); Oh, and a little correction: This doesnt working, its only works if the image is in the same folder of the program. This doesn't work. Its only working if the image is in the same folder as the program. ;););) Just kidding ;);););) Good luck!

      M 1 Reply Last reply
      0
      • P Peter Nirschl

        MoOnBoY wrote: Image.FromStream( f ); I think there is a better way! Just use: Image img = Image.FromFile("C:\\..."); Oh, and a little correction: This doesnt working, its only works if the image is in the same folder of the program. This doesn't work. Its only working if the image is in the same folder as the program. ;););) Just kidding ;);););) Good luck!

        M Offline
        M Offline
        moonboy
        wrote on last edited by
        #3

        The path is specificated by the USER... foto is the path, if I use: Image img = Image.FromFile( foto ); Only works if the path is the same of program folder....

        P C 2 Replies Last reply
        0
        • M moonboy

          The path is specificated by the USER... foto is the path, if I use: Image img = Image.FromFile( foto ); Only works if the path is the same of program folder....

          P Offline
          P Offline
          Peter Nirschl
          wrote on last edited by
          #4

          Let's say we have a textBox called textBox1. And let's say we hava a picture box called pictureBox1. We use pictureBox1 to view the image. The user types in the CORRECT path. The user clicks on a button. And now the button's OnClick event: Image img = Image.FromFile (this.textBox1.Text); this.pictureBox1.Image = img; Then add an error handling with TRY and CATCH. I've already tested this code. It MUST work.

          1 Reply Last reply
          0
          • M moonboy

            The path is specificated by the USER... foto is the path, if I use: Image img = Image.FromFile( foto ); Only works if the path is the same of program folder....

            C Offline
            C Offline
            Chad Smith
            wrote on last edited by
            #5

            If the path is specified by the user then use Image img = Image.FromFile ( @foto );

            A 1 Reply Last reply
            0
            • C Chad Smith

              If the path is specified by the user then use Image img = Image.FromFile ( @foto );

              A Offline
              A Offline
              amal_pro83
              wrote on last edited by
              #6

              as i understood that u ve image and u want to open it from stream file... 1-u cant use Image class as it is abstract one, so u cant define object from it 2-u use Bitmap class to open ur image //example: dont forget to use (Using System.Drawing) Bitmap myimage=new Bitmap(filestream,true); //constructor use true to make error correction..hope it works

              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