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 Offline
    V Offline
    viciouskinid
    wrote on last edited by
    #1

    Hi, I am wanting to learn a little about how a program saves data ie saved files for a game or a program. Is there a link anyone can recommend so I can learn how to create a professional file type that i can use in my program? I also have a program linguata that i am using to learn a foreign language. The way the program works is that it has a basic file structure and for each different language it has an ogg file (containing all the sound data) and another "lesson" file that has the word/phrase in english and the other language. it also has the specific time that the word/phrase appears in the ogg file. I want to be able to de-construct the "lesson" file so i can get the raw data for the program. with this i want to create word games to help me learn. the file is located http://rapidshare.com/files/237060596/lesson[^] is it possible to read it in anyway or is it encrypted? thanks

    L 1 Reply Last reply
    0
    • V viciouskinid

      Hi, I am wanting to learn a little about how a program saves data ie saved files for a game or a program. Is there a link anyone can recommend so I can learn how to create a professional file type that i can use in my program? I also have a program linguata that i am using to learn a foreign language. The way the program works is that it has a basic file structure and for each different language it has an ogg file (containing all the sound data) and another "lesson" file that has the word/phrase in english and the other language. it also has the specific time that the word/phrase appears in the ogg file. I want to be able to de-construct the "lesson" file so i can get the raw data for the program. with this i want to create word games to help me learn. the file is located http://rapidshare.com/files/237060596/lesson[^] is it possible to read it in anyway or is it encrypted? thanks

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

      Hi I like file types (yea I know that's strange, but really, I do) and in particular, decoding unknown file types. So therefore I will break the rule of not downloading strange files and dive right in. This file doesn't look encrypted, so that's good. And I'm using XVI32 to open it, btw. I suppose there are better hex editors but I kinda grew up with it.. So, the structure. After a little header (which only seems to contain a version number) there comes a big part of 64byte structs. I can't really say much about them without having a second file of the same type to compare it with though. But there are some things I can say. It definitely starts with an int, but I can't say what it means (could be a pointer to a record somewhere in an other section of the file). At first it seems to be rising, but that quickly stops. Then an other int, which is usually zero. Then an other int, which does seem to consistently rise (could be the time in the ogg file? a pointer into one of the records in an other section of the file?). Then just a bunch of zero's and the language name, it seems. Then after a whole bunch of zero's, there are pairs of words + translation. Looks like 16bit unicode. The records seem to have a fixed length of 164 bytes (so 82 chars, but most of them are \0) More zero's.. (do they waste space on purpose or what?) Then some untranslated words? strange More zero's.. Some rising numbers? Fun, I guess. Don't know what they do. More zero's.. It ends with some data that doesn't look particularly useful.. And a footer ": MMG " (possibly without the ":") It could turn out to be completely different of course.

      V 1 Reply Last reply
      0
      • L Lost User

        Hi I like file types (yea I know that's strange, but really, I do) and in particular, decoding unknown file types. So therefore I will break the rule of not downloading strange files and dive right in. This file doesn't look encrypted, so that's good. And I'm using XVI32 to open it, btw. I suppose there are better hex editors but I kinda grew up with it.. So, the structure. After a little header (which only seems to contain a version number) there comes a big part of 64byte structs. I can't really say much about them without having a second file of the same type to compare it with though. But there are some things I can say. It definitely starts with an int, but I can't say what it means (could be a pointer to a record somewhere in an other section of the file). At first it seems to be rising, but that quickly stops. Then an other int, which is usually zero. Then an other int, which does seem to consistently rise (could be the time in the ogg file? a pointer into one of the records in an other section of the file?). Then just a bunch of zero's and the language name, it seems. Then after a whole bunch of zero's, there are pairs of words + translation. Looks like 16bit unicode. The records seem to have a fixed length of 164 bytes (so 82 chars, but most of them are \0) More zero's.. (do they waste space on purpose or what?) Then some untranslated words? strange More zero's.. Some rising numbers? Fun, I guess. Don't know what they do. More zero's.. It ends with some data that doesn't look particularly useful.. And a footer ": MMG " (possibly without the ":") It could turn out to be completely different of course.

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

        GREAT! Thanks Two Questions though: first. ok so now I can see a readable version of the data how do i get access to it? how can I read it with C#? and second. The first bit of my original question. How do i make a file type myself. I have been using BinaryReader and giving the file the extension I like but it is easy to view the file again in paint. I want my filetype to be professional so it really shouldnt I shouldnt be able to read it in paint. Do you know of a link with an example project? Any ideas

        L 1 Reply Last reply
        0
        • V viciouskinid

          GREAT! Thanks Two Questions though: first. ok so now I can see a readable version of the data how do i get access to it? how can I read it with C#? and second. The first bit of my original question. How do i make a file type myself. I have been using BinaryReader and giving the file the extension I like but it is easy to view the file again in paint. I want my filetype to be professional so it really shouldnt I shouldnt be able to read it in paint. Do you know of a link with an example project? Any ideas

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

          I would read it with a BinaryReader What do you mean in paint? MS paint? You can trick it to load an exe if you wanted.. The structure of this file was not especially "professional", in fact, it just sucks. Sure it gets the job done - it saves the data. But file structures for Real Programmers contain funny data structures - heaps, trees, length-prefixed blocks, whatever you want except fixed length strings (they just waste space). There has also been a growing trend towards splitting your data in logical parts (if there is more than 1), zipping them all together, but giving it a custom extension (not .zip). Even .docx and .odt work this way. As a bonus it compresses your data so you can make the most ridiculously space wasting format you want and get away with it. "Nice" formats to look at to get an idea are (for example) png and bzip2

          V 1 Reply Last reply
          0
          • L Lost User

            I would read it with a BinaryReader What do you mean in paint? MS paint? You can trick it to load an exe if you wanted.. The structure of this file was not especially "professional", in fact, it just sucks. Sure it gets the job done - it saves the data. But file structures for Real Programmers contain funny data structures - heaps, trees, length-prefixed blocks, whatever you want except fixed length strings (they just waste space). There has also been a growing trend towards splitting your data in logical parts (if there is more than 1), zipping them all together, but giving it a custom extension (not .zip). Even .docx and .odt work this way. As a bonus it compresses your data so you can make the most ridiculously space wasting format you want and get away with it. "Nice" formats to look at to get an idea are (for example) png and bzip2

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

            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 1 Reply Last reply
            0
            • 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