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. Embedded Xml: Ok it work, but ... why?

Embedded Xml: Ok it work, but ... why?

Scheduled Pinned Locked Moved C#
questioncomhardwarexmlhelp
4 Posts 3 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
    nelsonpaixao
    wrote on last edited by
    #1

    Hi, I have png and xml files embedded in a project. I can access them with the code bellow.

    DataSet MyDataSet = new DataSet();
    Assembly ThisAssembly = Assembly.GetExecutingAssembly();
    // assign a image png to button
    Stream Stream_Image = ThisAssembly.GetManifestResourceStream("MyProject.Resources.info.png");
    Button_Info.Image = Image.FromStream(Stream_Image);

    // assign table to DataGridView
    Stream Stream_Xml = ThisAssembly.GetManifestResourceStream("MyProject.Resources.users.xml");
    MyDataSet.ReadXml(Stream_Xml); // why does this work???
    DataGridView_Report.DataSource = MyDataSet.Tables[0];

    OK. For the png i got it, but ... for the xml why does it work? :doh:

    MyDataSet.ReadXml(Application.StartupPath + "\\...\\users.xml", XmlReadMode.ReadSchema));

    This i understand, (not embedded although) the path way, here i really reading a xml not a stream.

    nelsonpaixao@yahoo.com.br trying to help & get help

    G A N 3 Replies Last reply
    0
    • N nelsonpaixao

      Hi, I have png and xml files embedded in a project. I can access them with the code bellow.

      DataSet MyDataSet = new DataSet();
      Assembly ThisAssembly = Assembly.GetExecutingAssembly();
      // assign a image png to button
      Stream Stream_Image = ThisAssembly.GetManifestResourceStream("MyProject.Resources.info.png");
      Button_Info.Image = Image.FromStream(Stream_Image);

      // assign table to DataGridView
      Stream Stream_Xml = ThisAssembly.GetManifestResourceStream("MyProject.Resources.users.xml");
      MyDataSet.ReadXml(Stream_Xml); // why does this work???
      DataGridView_Report.DataSource = MyDataSet.Tables[0];

      OK. For the png i got it, but ... for the xml why does it work? :doh:

      MyDataSet.ReadXml(Application.StartupPath + "\\...\\users.xml", XmlReadMode.ReadSchema));

      This i understand, (not embedded although) the path way, here i really reading a xml not a stream.

      nelsonpaixao@yahoo.com.br trying to help & get help

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      There isn't really any difference between PNG data and XML data, it's only a bunch of bytes. Reading a stream of bytes as a PNG image or reading a stream of bytes as an XML document makes no difference for the stream that you are reading from.

      Despite everything, the person most likely to be fooling you next is yourself.

      1 Reply Last reply
      0
      • N nelsonpaixao

        Hi, I have png and xml files embedded in a project. I can access them with the code bellow.

        DataSet MyDataSet = new DataSet();
        Assembly ThisAssembly = Assembly.GetExecutingAssembly();
        // assign a image png to button
        Stream Stream_Image = ThisAssembly.GetManifestResourceStream("MyProject.Resources.info.png");
        Button_Info.Image = Image.FromStream(Stream_Image);

        // assign table to DataGridView
        Stream Stream_Xml = ThisAssembly.GetManifestResourceStream("MyProject.Resources.users.xml");
        MyDataSet.ReadXml(Stream_Xml); // why does this work???
        DataGridView_Report.DataSource = MyDataSet.Tables[0];

        OK. For the png i got it, but ... for the xml why does it work? :doh:

        MyDataSet.ReadXml(Application.StartupPath + "\\...\\users.xml", XmlReadMode.ReadSchema));

        This i understand, (not embedded although) the path way, here i really reading a xml not a stream.

        nelsonpaixao@yahoo.com.br trying to help & get help

        A Offline
        A Offline
        Anthony Mushrow
        wrote on last edited by
        #3

        There is no difference at all. When you pass a path it goes and opens the file (which ends up as a stream), and when you pass it a stream - well, its already a stream. A stream is just a pile of data, in memory, on your hard disk, coming over a network; it's all quite similar.

        My current favourite word is: Nipple!

        -SK Genius

        Game Programming articles start -here[^]-

        1 Reply Last reply
        0
        • N nelsonpaixao

          Hi, I have png and xml files embedded in a project. I can access them with the code bellow.

          DataSet MyDataSet = new DataSet();
          Assembly ThisAssembly = Assembly.GetExecutingAssembly();
          // assign a image png to button
          Stream Stream_Image = ThisAssembly.GetManifestResourceStream("MyProject.Resources.info.png");
          Button_Info.Image = Image.FromStream(Stream_Image);

          // assign table to DataGridView
          Stream Stream_Xml = ThisAssembly.GetManifestResourceStream("MyProject.Resources.users.xml");
          MyDataSet.ReadXml(Stream_Xml); // why does this work???
          DataGridView_Report.DataSource = MyDataSet.Tables[0];

          OK. For the png i got it, but ... for the xml why does it work? :doh:

          MyDataSet.ReadXml(Application.StartupPath + "\\...\\users.xml", XmlReadMode.ReadSchema));

          This i understand, (not embedded although) the path way, here i really reading a xml not a stream.

          nelsonpaixao@yahoo.com.br trying to help & get help

          N Offline
          N Offline
          nelsonpaixao
          wrote on last edited by
          #4

          Ok then i got it. The more i know the more i realize i dont know :laugh: thanks

          nelsonpaixao@yahoo.com.br trying to help & get help

          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