File types
-
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
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
-
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
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.
-
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.
-
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?
-
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?
-
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
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.
-
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.
-
no that doesnt work either. is this correct in my code? byte[] st=r.ReadBytes(8);
-
no that doesnt work either. is this correct in my code? byte[] st=r.ReadBytes(8);
-
It depends on the place. GetString might not like too many zero's so it might be good to remove them..
I really have no idea. Do you think you would be able to get it to work and share the code with me?
-
I really have no idea. Do you think you would be able to get it to work and share the code with me?
-
Ah I don't know, have you tried looking at what the byte array contains before stringing it? Probably.. but.. what was in it?
Thanks for all your help. I was able to get the code for a c# hex editor and it helped me figure it out.