Save the bytes of a file

0

I'm doing an application that needs to read the bytes of a fixed file, I'm able to read clearly, however, it bothers me that the file needs to keep track of my application every time it starts. By any chance do you have to 'save' these bytes inside my application or something like this?

    
asked by anonymous 17.07.2017 / 09:12

1 answer

3

Think about it, there is no miracle. You want to take data from a file and put your content inside your code. In the end this data remains saved somewhere - in its sources or binaries. So, why do you care?

Add this file to the project, check to always copy the file in the builds and touch the solution. Now, if you really want to do this:

Read the file data, create a buffer and then create that buffer as C # code.

var buffer = File.ReadAllBytes(caminhoDoArquivoBinario);
System.Diagnostics.Debugger.Break(); // breakpoint após a leitura do buffer

Then go to Imediate Window and do:

buffer <ENTER>

Copy what was generated and paste into some .cs .

    
17.07.2017 / 09:45