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. Copy raw file image

Copy raw file image

Scheduled Pinned Locked Moved C#
comquestion
31 Posts 7 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.
  • D Dave Kreskowiak

    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

    D Offline
    D Offline
    devvvy
    wrote on last edited by
    #21

    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

    D 1 Reply Last reply
    0
    • D devvvy

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #22

      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

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

        D Offline
        D Offline
        devvvy
        wrote on last edited by
        #23

        and why do you think Covean gave me the answer I was looking for? There's troops of losers littering this forum these days - like i said, if you have no better to say just move on and play with yourself

        dev

        1 Reply Last reply
        0
        • D devvvy

          Covean did - learn post only if you have something to offer mate

          dev

          T Offline
          T Offline
          Thomas Krojer
          wrote on last edited by
          #24

          @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 ...

          D 1 Reply Last reply
          0
          • C Covean

            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

            T Offline
            T Offline
            Thomas Krojer
            wrote on last edited by
            #25

            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"?

            C 1 Reply Last reply
            0
            • T Thomas Krojer

              @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 ...

              D Offline
              D Offline
              devvvy
              wrote on last edited by
              #26

              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

              T 1 Reply Last reply
              0
              • D devvvy

                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

                T Offline
                T Offline
                Thomas Krojer
                wrote on last edited by
                #27

                your welcome

                D 1 Reply Last reply
                0
                • T Thomas Krojer

                  your welcome

                  D Offline
                  D Offline
                  devvvy
                  wrote on last edited by
                  #28

                  I must have made a mistake - I thought I tried ReadAllBytes too but apparently not.

                  dev

                  1 Reply Last reply
                  0
                  • T Thomas Krojer

                    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"?

                    C Offline
                    C Offline
                    Covean
                    wrote on last edited by
                    #29

                    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

                    T 1 Reply Last reply
                    0
                    • C Covean

                      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

                      T Offline
                      T Offline
                      Thomas Krojer
                      wrote on last edited by
                      #30

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

                      1 Reply Last reply
                      0
                      • D devvvy

                        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

                        C Offline
                        C Offline
                        Covean
                        wrote on last edited by
                        #31

                        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

                        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