|
for what reasons?
I like the readability aspect of the xml, but I saw that article about the default serialisation being quite wasteful in terms of space, and was thinking if I could apply better serialisation without much effort then I would.
|
|
|
|
|
cjb110 wrote: for what reasons?
Performance (and storage size). Of course XML is more readable and maintainable, but it comes at the expense of performance and the size of the store. If you're storing a couple of hundred objects, this won't be an issue. But if you're storing thousands, it likely will.
/ravi
|
|
|
|
|
hi.
how can read/write image from/to server?
thanks.
|
|
|
|
|
Using sockets[^] is one option.
It's time for a new signature.
|
|
|
|
|
|
You don't use an encoding. Encodings interpret the values read. You won't get the actual data from the file.
Use System.Io.File.ReadAllBytes[^].
|
|
|
|
|
|
ReadAllBytes as the name implies reads all bytes, regardless of what they should be interpreted as. Its up to you to then translate them into whatever it is you wish.
If the post was helpful, please vote, eh!
Current activities:
Playing Star Craft II. Don't bother me, eh?
Now and forever, defiant to the end.
What is Multiple Sclerosis[ ^]?
|
|
|
|
|
I ran a simple experiement, read all byte of HelloWorld.exe and write it to second file - it didn't run and OS complained invalid image
dev
|
|
|
|
|
Consider, if such a simple feature did not work then it would not be possible to do any form of data copying under Windows. Try showing your code, there must be an error somewhere.
It's time for a new signature.
|
|
|
|
|
How did you write the new file? Post your code snipplet.
|
|
|
|
|
Then you did something else wrong in your code. Post the read and write sections and we may be able to tell you where that is.
|
|
|
|
|
Yeah, it will work since I used it to read and parse PE format executables myself.
|
|
|
|
|
what do you mean by "raw file image"?
is it a file containing an image (i.e. header plus pixel data)?
is it a file containing the raw data of an image (i.e. pixel data only)?
is it the "image" of an executaable?
you can read( or write) all the bytes of a file at once using File.ReadAllBytes (WriteAllBytes).
If you don't want to have them all at once in memory, use a BinaryReader (BinaryWriter).
And what do you mean by "encoding"?
if it refers to the Encoding class, that one only applies to text.
if it refers to the way pixels get represented, that one is called PixelFormat.
Please learn to ask questions properly.
And don't say "it didn't run and OS complained invalid image", show the code and the exact compile-time or run-time error message(s).
|
|
|
|
|
|
No I do not understand you, you fail to provide necessary information and ask a clear question.
And no I did not suggest anything would be possible or impossible, as it is still completely unclear what you want in the first place.
Now stop reading things that are not present; and start providing information that is necessary but missing.
|
|
|
|
|
Covean did - learn post only if you have something to offer mate
dev
|
|
|
|
|
Please don't remove any messages that have been replied to. It is against the forum guidelines as it results in messy threads.
Yours said:
thanks yes you understand me - i will post the code but you're suggesting this can't be done in dotnet?
which is what you also replied to Covean !?!?!?
|
|
|
|
|
I figured originally i intend to reply to Covean, but instead went to you. To avoid further confusion I removed it (MOVED back to under Covean's thread)
dev
|
|
|
|
|
@devvvy: YOU don´t understand: You were asked to provide the piece of code making troubles .... you didn´t, instead you started to moan ... ANYWAY:
byte[] an_image = File.ReadAllBytes("hello_world.exe");
File.WriteAllBytes("another_hello_world.exe", an_image);
No P/Invoke, not really difficult ...
|
|
|
|
|
hey thanks it works!
<br />
static void Main(string[] args)<br />
{<br />
string TargetFile = null;<br />
byte[] an_image = null;<br />
<br />
try<br />
{<br />
TargetFile = args[0];<br />
<br />
if (!string.IsNullOrEmpty(TargetFil ))<br />
{<br />
an_image = File.ReadAllBytes(TargetFile );<br />
File.WriteAllBytes("SomeClone.exe", an_image);<br />
}<br />
}<br />
catch (Exception Ex)<br />
{<br />
Console.WriteLine("Yike");<br />
}<br />
<br />
return;<br />
}<br />
dev
modified on Wednesday, August 11, 2010 4:30 AM
|
|
|
|
|
|
I must have made a mistake - I thought I tried ReadAllBytes too but apparently not.
dev
|
|
|
|
|
If I'm right then he asks for a way to read all the file data plus the file system (NTFS as example) specific information.
On a hard disk there are also a file header / footer for every file.
Now this data he wants to read (and maybe) write.
1. Handle a file is the wrong approach you have to handle the file system in your case.
2. There is no class (or?) to read/write from/to the hard disk at this i/o level in C#.
3. Take a look at CreateFile. There is a possibility to read the physical disk.
Greetings
Covean
|
|
|
|
|
thanks yes you understand me - i will post the code but you're suggesting this can't be done in dotnet?
dev
|
|
|
|