Copy raw file image
-
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 !?!?!? X|
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
He didn't "understand" you. He frickin' guessed at it using the link you posted and your replies in this thread. I took a look at the link and guessed that you were trying to read the entire contents of the file, uninterpreted, because of the HexEdit screen shots in the link and your mentioning of using Encoding to read the file. You made no mention at all of what you were ultimately trying to do with this information. Luc is correct. You still don't know how to ask a question in a format that is answerable, nor do you provide any of the details to questions that would fill in the missing bits of information critical to giving you the correct answer on the first try. You've demonstrated a history of this. People have to constantly guess at what you're talking about.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
screw you sis go find someone else to argue with, if you don't know the sh*t, don't litter the forum pass on to another thread which you actually have something to offer
dev
The only way someone can actually offer you anything useful is if they take a wild ass guess at what your trying to do.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
The only way someone can actually offer you anything useful is if they take a wild ass guess at what your trying to do.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
@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 ...
-
This can be done in .NET / C# by using PInvoke. But on the other hand I think that accessing the file system directly from C# should be avoided. If you have problems to get started with this, google for "PInvoke" and try to figure out how to call Windows API from within C#. PS: To get a better start with this forum and all those helper/cpians here, please read the pinned forum guidelines at the start and try to think about / rephrase your question. One more sentences could avoid further inquiry.
Greetings Covean
Covean wrote:
This can be done in .NET / C# by using PInvoke.
It can be done WITHOUT P/Invoke
Covean wrote:
But on the other hand I think that accessing the file system directly from C# should be avoided.
Why? For what reason is the namespace "System.IO"?
-
@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!
static void Main(string[] args) { string TargetFile = null; byte[] an_image = null; try { TargetFile = args[0]; if (!string.IsNullOrEmpty(TargetFil )) { an_image = File.ReadAllBytes(TargetFile ); File.WriteAllBytes("SomeClone.exe", an_image); } } catch (Exception Ex) { Console.WriteLine("Yike"); } return; }
dev
modified on Wednesday, August 11, 2010 4:30 AM
-
hey thanks it works!
static void Main(string[] args) { string TargetFile = null; byte[] an_image = null; try { TargetFile = args[0]; if (!string.IsNullOrEmpty(TargetFil )) { an_image = File.ReadAllBytes(TargetFile ); File.WriteAllBytes("SomeClone.exe", an_image); } } catch (Exception Ex) { Console.WriteLine("Yike"); } return; }
dev
modified on Wednesday, August 11, 2010 4:30 AM
your welcome
-
your welcome
-
Covean wrote:
This can be done in .NET / C# by using PInvoke.
It can be done WITHOUT P/Invoke
Covean wrote:
But on the other hand I think that accessing the file system directly from C# should be avoided.
Why? For what reason is the namespace "System.IO"?
-
And what class from System.IO allows direct access to the hard disk/file system (and how)? And as I mentioned before, I don't know if there is a way without PInvoke, this doesn't mean there is no way!
Greetings Covean
The original question was NOT about raw disc access, but raw FILE access, therefore the solution without api calls. And of course, direct disc access is only possible through CreateFile or CreateFileTransacted - api calls. And I fully agree, that this should only be done if you know exactly what you are doing. BUT if you do it, use the language you know best ...
-
Covean wrote:
If you have problems to get started with this, google for "PInvoke" and try to figure out how to call Windows API from within C#.
I understand pinvoke, but why ... that such things done via platform win32 api better...?
dev
I just only know this way ... so why should be something better to the only way I know ... better than what? Let me know if you know an other way, than maybe we could speak about things like that one way is better than the other ... but how should I be able to tell you if win32 api platform invoke is better than ... what???
Greetings Covean