111,126
社区成员
发帖
与我相关
我的任务
分享 //方法用"unsafe"修饰(选择项目属性-->生成-->勾选允许不安全代码)
static unsafe void Main(string[] args)
{
string str_dst = "C:\\test1.jpg\0";//"\0"标识字符串结束
IntPtr pt_dst = System.Runtime.InteropServices.Marshal.AllocHGlobal(str_dst.Length*2);
System.Runtime.InteropServices.Marshal.Copy(str_dst.ToCharArray(), 0, pt_dst, str_dst.Length);
byte* dst = (byte*)pt_dst;
string str_src = "D:\\test2.jpg\0";
IntPtr pt_src = System.Runtime.InteropServices.Marshal.AllocHGlobal(str_src.Length*2);
System.Runtime.InteropServices.Marshal.Copy(str_src.ToCharArray(), 0, pt_src, str_src.Length);
byte* src = (byte*)pt_src;
Package.Lz77.encode(dst,src, 0);
}