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. Detecting the Path. Please help!

Detecting the Path. Please help!

Scheduled Pinned Locked Moved C#
questiondebugginghelp
10 Posts 2 Posters 2 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.
  • D Offline
    D Offline
    deanoA
    wrote on last edited by
    #1

    Hi! I have the following code: Stream stream = new FileStream("Form1.resx", FileMode.Open); And the default directory for Form1 is in WindowsApplication1\Bin\Debug right? But I want to use the resx in the WindowsApplication folder. How do I do this? Please help this newbie. :( "To teach is to learn twice"

    A 1 Reply Last reply
    0
    • D deanoA

      Hi! I have the following code: Stream stream = new FileStream("Form1.resx", FileMode.Open); And the default directory for Form1 is in WindowsApplication1\Bin\Debug right? But I want to use the resx in the WindowsApplication folder. How do I do this? Please help this newbie. :( "To teach is to learn twice"

      A Offline
      A Offline
      Alexander Kojevnikov
      wrote on last edited by
      #2

      Form's .resx file is an embedded resource. This means you can access it as shown below:

      Assembly assembly = Assembly.GetEntryAssembly();
      Stream stream = assembly.GetManifestResourceStream(
      "WindowsApplication1.Form1.resx");

      Alexandre Kojevnikov MCAD charter member Leuven, Belgium

      D 1 Reply Last reply
      0
      • A Alexander Kojevnikov

        Form's .resx file is an embedded resource. This means you can access it as shown below:

        Assembly assembly = Assembly.GetEntryAssembly();
        Stream stream = assembly.GetManifestResourceStream(
        "WindowsApplication1.Form1.resx");

        Alexandre Kojevnikov MCAD charter member Leuven, Belgium

        D Offline
        D Offline
        deanoA
        wrote on last edited by
        #3

        What namespace will i add for this? Thanks in advance!!:) "To teach is to learn twice"

        A 2 Replies Last reply
        0
        • D deanoA

          What namespace will i add for this? Thanks in advance!!:) "To teach is to learn twice"

          A Offline
          A Offline
          Alexander Kojevnikov
          wrote on last edited by
          #4

          daljv wrote: What namespace will i add for this? Whichever you find appropriate. Just don't forget to update the parameter of GetManifestResourceStream() to "Namespace.Of.Form1.resx". Alexandre Kojevnikov MCAD charter member Leuven, Belgium

          D 1 Reply Last reply
          0
          • D deanoA

            What namespace will i add for this? Thanks in advance!!:) "To teach is to learn twice"

            A Offline
            A Offline
            Alexander Kojevnikov
            wrote on last edited by
            #5

            I probably misunderstood your question. You will need: System.Reflection and System.IO. Alexandre Kojevnikov MCAD charter member Leuven, Belgium

            D 1 Reply Last reply
            0
            • A Alexander Kojevnikov

              daljv wrote: What namespace will i add for this? Whichever you find appropriate. Just don't forget to update the parameter of GetManifestResourceStream() to "Namespace.Of.Form1.resx". Alexandre Kojevnikov MCAD charter member Leuven, Belgium

              D Offline
              D Offline
              deanoA
              wrote on last edited by
              #6

              Hi! I used the follwing code: Assembly assembly = Assembly.GetEntryAssembly(); Stream stream = assembly.GetManifestResourceStream("WindowsApplication7.Form1.resx"); ResourceReader a = new ResourceReader(stream); IDictionaryEnumerator en = a.GetEnumerator(); en.MoveNext(); MessageBox.Show(en.Key.ToString()); MessageBox.Show(en.Value.ToString()); a.Close(); But I get an exception stating that: An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll Additional information: Value cannot be null. Why is this? "To teach is to learn twice"

              1 Reply Last reply
              0
              • A Alexander Kojevnikov

                I probably misunderstood your question. You will need: System.Reflection and System.IO. Alexandre Kojevnikov MCAD charter member Leuven, Belgium

                D Offline
                D Offline
                deanoA
                wrote on last edited by
                #7

                Hi! I used the follwing code: Assembly assembly = Assembly.GetEntryAssembly(); Stream stream = assembly.GetManifestResourceStream("WindowsApplication7.Form1.resx"); ResourceReader a = new ResourceReader(stream); IDictionaryEnumerator en = a.GetEnumerator(); en.MoveNext(); MessageBox.Show(en.Key.ToString()); MessageBox.Show(en.Value.ToString()); a.Close(); But I get an exception stating that: An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll Additional information: Value cannot be null. Why is this? "To teach is to learn twice"

                A 1 Reply Last reply
                0
                • D deanoA

                  Hi! I used the follwing code: Assembly assembly = Assembly.GetEntryAssembly(); Stream stream = assembly.GetManifestResourceStream("WindowsApplication7.Form1.resx"); ResourceReader a = new ResourceReader(stream); IDictionaryEnumerator en = a.GetEnumerator(); en.MoveNext(); MessageBox.Show(en.Key.ToString()); MessageBox.Show(en.Value.ToString()); a.Close(); But I get an exception stating that: An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll Additional information: Value cannot be null. Why is this? "To teach is to learn twice"

                  A Offline
                  A Offline
                  Alexander Kojevnikov
                  wrote on last edited by
                  #8

                  Replace WindowsApplication7.Form1.resx with WindowsApplication7.Form1.resources. This should work. Alexandre Kojevnikov MCAD charter member Leuven, Belgium

                  D 1 Reply Last reply
                  0
                  • A Alexander Kojevnikov

                    Replace WindowsApplication7.Form1.resx with WindowsApplication7.Form1.resources. This should work. Alexandre Kojevnikov MCAD charter member Leuven, Belgium

                    D Offline
                    D Offline
                    deanoA
                    wrote on last edited by
                    #9

                    It now works!:) Thanks a Trillion!! You have learned twice!!:) "To teach is to learn twice"

                    A 1 Reply Last reply
                    0
                    • D deanoA

                      It now works!:) Thanks a Trillion!! You have learned twice!!:) "To teach is to learn twice"

                      A Offline
                      A Offline
                      Alexander Kojevnikov
                      wrote on last edited by
                      #10

                      daljv wrote: You have learned twice Indeed :) Alexandre Kojevnikov MCAD charter member Leuven, Belgium

                      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