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. Visual Basic
  4. writing a timestamp to a xml file.

writing a timestamp to a xml file.

Scheduled Pinned Locked Moved Visual Basic
announcementtoolsxmlhelp
6 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.
  • M Offline
    M Offline
    malcomhfc
    wrote on last edited by
    #1

    Hey all. On a new project im working on, which is about learning different areas in visual basic. One area i havnt covered much is writing to files and retrieving data from a file. The program includes a update script, which justs checks online reading a .txt file to see if the version is newer, if so it downloads it. I would like to record when the user last press 'checkForUpdates' button. Take the timestamp and write it into a xml file. Then using a simple label to read and display the value inside the xml file. I have been trying a few ways, just using timestamps i got lost. Any help would be great, Malcom

    D 1 Reply Last reply
    0
    • M malcomhfc

      Hey all. On a new project im working on, which is about learning different areas in visual basic. One area i havnt covered much is writing to files and retrieving data from a file. The program includes a update script, which justs checks online reading a .txt file to see if the version is newer, if so it downloads it. I would like to record when the user last press 'checkForUpdates' button. Take the timestamp and write it into a xml file. Then using a simple label to read and display the value inside the xml file. I have been trying a few ways, just using timestamps i got lost. Any help would be great, Malcom

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      If you can show the code you have tried and explain the exact problem, it would be easier to help.

      It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

      M 1 Reply Last reply
      0
      • D dan sh

        If you can show the code you have tried and explain the exact problem, it would be easier to help.

        It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

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

        Oki sorry, i asked wrong, i have tried some ways but i can't get it to work. Im not asking for the answer, that be wrong. I am learning it afterall. I just need say a boost. Just a quick example of generating a timestamp then i can work it from there. I did some googling and believe i can easly use xml file just need to mess around abit more. Sorry for the bother, Malcom

        D F 2 Replies Last reply
        0
        • M malcomhfc

          Oki sorry, i asked wrong, i have tried some ways but i can't get it to work. Im not asking for the answer, that be wrong. I am learning it afterall. I just need say a boost. Just a quick example of generating a timestamp then i can work it from there. I did some googling and believe i can easly use xml file just need to mess around abit more. Sorry for the bother, Malcom

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          DateTime.Now will give you the current time. And then, you can look into the classes in System.Xml namespace to write that to your XML file.

          It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

          1 Reply Last reply
          0
          • M malcomhfc

            Oki sorry, i asked wrong, i have tried some ways but i can't get it to work. Im not asking for the answer, that be wrong. I am learning it afterall. I just need say a boost. Just a quick example of generating a timestamp then i can work it from there. I did some googling and believe i can easly use xml file just need to mess around abit more. Sorry for the bother, Malcom

            F Offline
            F Offline
            freakyit
            wrote on last edited by
            #5

            hi, here i have some code for you.

            System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter("C:\\timestamp.xml",System.Text.Encoding.UTF8);

            // XmlFormatting
            xtw.Formatting == Formatting.Indented;
            xtw.Indentation = 4;

            xtw.WriteStartDocument();

            // write into a element as inner text
            xtw.WriteStartElement("TimeStamp");
            xtw.WriteString(DateTime.Now.ToOADate());
            xtw.WriteEndElement();

            // Write into a element as attribute
            xtw.WriteStartElement("TimeStampAttribute");
            xtw.WriteAttributeString("DateTime",DateTime.Now.ToOADate())
            xtw.WriteEndElement();

            xtw.WriteEndDocument();
            xtw.Close();

            M 1 Reply Last reply
            0
            • F freakyit

              hi, here i have some code for you.

              System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter("C:\\timestamp.xml",System.Text.Encoding.UTF8);

              // XmlFormatting
              xtw.Formatting == Formatting.Indented;
              xtw.Indentation = 4;

              xtw.WriteStartDocument();

              // write into a element as inner text
              xtw.WriteStartElement("TimeStamp");
              xtw.WriteString(DateTime.Now.ToOADate());
              xtw.WriteEndElement();

              // Write into a element as attribute
              xtw.WriteStartElement("TimeStampAttribute");
              xtw.WriteAttributeString("DateTime",DateTime.Now.ToOADate())
              xtw.WriteEndElement();

              xtw.WriteEndDocument();
              xtw.Close();

              M Offline
              M Offline
              malcomhfc
              wrote on last edited by
              #6

              Thank you both. I tried your hints and i got somewhere. Just was hitting a wall. The time was coming out as 00:00:00. To the last replier before me, thanks for the code, really gave me a better idea of what i needed. Thanks :D

              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