Created
February 8, 2016 13:21
-
-
Save ahmetabdi/b1a0ec09a13166d288ae to your computer and use it in GitHub Desktop.
DLL to byte [], byte [] to String, String to byte []
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using System.IO; | |
namespace ConsoleApplication | |
{ | |
public class Program | |
{ | |
public void Main(string[] args) | |
{ | |
Console.WriteLine(Path.GetTempPath()); | |
string dllPath = String.Format("{0}/PigDll.dll", Path.GetTempPath()); | |
// From Dll to byte array | |
byte[] buffer = System.IO.File.ReadAllBytes(dllPath); | |
// From byte array to string | |
string s = System.Text.Encoding.UTF8.GetString(buffer, 0, buffer.Length); | |
// From string to byte array | |
byte[] buffer2 = System.Text.Encoding.UTF8.GetBytes(s); | |
Console.WriteLine(buffer2.Length); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment