Encode / Decode .EXE into Base64

The problem was caused by: Get-Content without -raw splits the file into an array of lines thus destroying the code Text.Encoding interprets the binary code as text thus destroying the code Out-File is for text data, not binary code The correct approach is to use IO.File ReadAllBytes: $base64string = [Convert]::ToBase64String([IO.File]::ReadAllBytes($FileName)) and WriteAllBytes to decode: [IO.File]::WriteAllBytes($FileName, … Read more

difference between text file and binary file

At the bottom level, they are all bits… true. However, some transmission channels have seven bits per byte, and other transmission channels have eight bits per byte. If you transmit ASCII text over a seven-bit channel, then all is fine. Binary data gets mangled. Additionally, different systems use different conventions for line endings: LF and … Read more

Read binary file into a struct

The problem is the strings in your struct. I found that marshaling types like byte/short/int is not a problem; but when you need to marshal into a complex type such as a string, you need your struct to explicitly mimic an unmanaged type. You can do this with the MarshalAs attrib. For your example, the … Read more

How to check if the file is a binary file and read all the files which are not?

Use utility file, sample usage: $ file /bin/bash /bin/bash: Mach-O universal binary with 2 architectures /bin/bash (for architecture x86_64): Mach-O 64-bit executable x86_64 /bin/bash (for architecture i386): Mach-O executable i386 $ file /etc/passwd /etc/passwd: ASCII English text $ file code.c code.c: ASCII c program text file manual page

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)