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. File types

File types

Scheduled Pinned Locked Moved C#
comgame-devhelptutorialquestion
15 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.
  • V viciouskinid

    sorry I meant c# not paint. dont know why i wrote that! Can you give me an idea how I can read the data with C#? or is there a way to output to a format that I can use with c#? Regarding the other question. I have a simple datatable that I want to save to a file. How should I do this. Thanks for the help.

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #6
    1. use BinaryReader 2) use BinaryWriter
    V 1 Reply Last reply
    0
    • L Lost User
      1. use BinaryReader 2) use BinaryWriter
      V Offline
      V Offline
      viciouskinid
      wrote on last edited by
      #7

      i am trying to with the following code: OpenFileDialog fd = new OpenFileDialog(); if (fd.ShowDialog() == DialogResult.OK) { FileStream streamR = new FileStream(fd.FileName, FileMode.Open); BinaryReader r = new BinaryReader(streamR); int count=0; while (true) {string st=r.ReadString(); if ((count > 374855)&&(st != string.Empty)) MessageBox.Show(count+"|"+st+"|"); count++; } } I am not getting anything i can read. Any ideas?

      L 1 Reply Last reply
      0
      • V viciouskinid

        i am trying to with the following code: OpenFileDialog fd = new OpenFileDialog(); if (fd.ShowDialog() == DialogResult.OK) { FileStream streamR = new FileStream(fd.FileName, FileMode.Open); BinaryReader r = new BinaryReader(streamR); int count=0; while (true) {string st=r.ReadString(); if ((count > 374855)&&(st != string.Empty)) MessageBox.Show(count+"|"+st+"|"); count++; } } I am not getting anything i can read. Any ideas?

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

        ReadString expects a crazy string format that no one uses except WriteString in BinaryWriter You could read a byte array and use Encoding.UTF16.GetString(bytes) or something like that

        V 1 Reply Last reply
        0
        • L Lost User

          ReadString expects a crazy string format that no one uses except WriteString in BinaryWriter You could read a byte array and use Encoding.UTF16.GetString(bytes) or something like that

          V Offline
          V Offline
          viciouskinid
          wrote on last edited by
          #9

          ok still no luck I tried the code below: OpenFileDialog fd = new OpenFileDialog(); if (fd.ShowDialog() == DialogResult.OK) { // fd.FileName; // FileStream streamR = new FileStream(fd.FileName, FileMode.Open); BinaryReader r = new BinaryReader(streamR); int count=0; while (true) {byte[] st=r.ReadBytes(8); if ((count > 374855) && (Encoding.UTF8.GetString(st)!=string.Empty)) MessageBox.Show(count + "|" + Encoding.UTF8.GetString(st) + "|"); count++; } } I used UTF8 because there wasnt a UTF16.

          L 1 Reply Last reply
          0
          • V viciouskinid

            ok still no luck I tried the code below: OpenFileDialog fd = new OpenFileDialog(); if (fd.ShowDialog() == DialogResult.OK) { // fd.FileName; // FileStream streamR = new FileStream(fd.FileName, FileMode.Open); BinaryReader r = new BinaryReader(streamR); int count=0; while (true) {byte[] st=r.ReadBytes(8); if ((count > 374855) && (Encoding.UTF8.GetString(st)!=string.Empty)) MessageBox.Show(count + "|" + Encoding.UTF8.GetString(st) + "|"); count++; } } I used UTF8 because there wasnt a UTF16.

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

            Hm.. try Encoding.Unicode?

            V 1 Reply Last reply
            0
            • L Lost User

              Hm.. try Encoding.Unicode?

              V Offline
              V Offline
              viciouskinid
              wrote on last edited by
              #11

              no that doesnt work either. is this correct in my code? byte[] st=r.ReadBytes(8);

              L 1 Reply Last reply
              0
              • V viciouskinid

                no that doesnt work either. is this correct in my code? byte[] st=r.ReadBytes(8);

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

                It depends on the place. GetString might not like too many zero's so it might be good to remove them..

                V 1 Reply Last reply
                0
                • L Lost User

                  It depends on the place. GetString might not like too many zero's so it might be good to remove them..

                  V Offline
                  V Offline
                  viciouskinid
                  wrote on last edited by
                  #13

                  I really have no idea. Do you think you would be able to get it to work and share the code with me?

                  L 1 Reply Last reply
                  0
                  • V viciouskinid

                    I really have no idea. Do you think you would be able to get it to work and share the code with me?

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

                    Ah I don't know, have you tried looking at what the byte array contains before stringing it? Probably.. but.. what was in it?

                    V 1 Reply Last reply
                    0
                    • L Lost User

                      Ah I don't know, have you tried looking at what the byte array contains before stringing it? Probably.. but.. what was in it?

                      V Offline
                      V Offline
                      viciouskinid
                      wrote on last edited by
                      #15

                      Thanks for all your help. I was able to get the code for a c# hex editor and it helped me figure it out.

                      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