c#怎么实现替换exe中的字符串
                 	
                        发表在C#图书答疑
                        2016-09-16                                                
                    		
                                                                            	
                        
                        
                    
                    
                    	是否精华
                    	是
                    	否
                    
                    
                    
                            版块置顶:
                            是
                            否
                        
                    
                                           c#怎么实现替换exe中的字符串。搞了2天也没解决,下面代码能替换字节数组但是不能替换exe中的字符串。
private byte[] 字节数组替换(byte[] 原字节数组, byte[] 欲被替换的字节数组, byte[] 用作替换字节数组)
{
List<byte> 搜列集合 = new List<byte>();
int i;
for (i = 0; i <= 原字节数组.Length - 欲被替换的字节数组.Length; i++)
{
bool 逻辑 = true;
for (int j = 0; j < 欲被替换的字节数组.Length; j++)
{
if (原字节数组[i + j] != 欲被替换的字节数组[j])
{
逻辑 = false;
break;
}
}
if (逻辑)
{
搜列集合.AddRange(用作替换字节数组);
i += 欲被替换的字节数组.Length - 1;
}
else
{
搜列集合.Add(原字节数组[i]);
}
}
for (; i < 原字节数组.Length; i++)
{
搜列集合.Add(原字节数组[i]);
}
return 搜列集合.ToArray();
}
public void 创建文件File(string 路径, byte[] 欲写出的字节数组)
{
            
            
if (File.Exists(路径))
{
File.Delete(路径);
}
File.WriteAllBytes(路径, 欲写出的字节数组);
            
}
QQ:260987762
                
        	
        
        
    private byte[] 字节数组替换(byte[] 原字节数组, byte[] 欲被替换的字节数组, byte[] 用作替换字节数组)
{
List<byte> 搜列集合 = new List<byte>();
int i;
for (i = 0; i <= 原字节数组.Length - 欲被替换的字节数组.Length; i++)
{
bool 逻辑 = true;
for (int j = 0; j < 欲被替换的字节数组.Length; j++)
{
if (原字节数组[i + j] != 欲被替换的字节数组[j])
{
逻辑 = false;
break;
}
}
if (逻辑)
{
搜列集合.AddRange(用作替换字节数组);
i += 欲被替换的字节数组.Length - 1;
}
else
{
搜列集合.Add(原字节数组[i]);
}
}
for (; i < 原字节数组.Length; i++)
{
搜列集合.Add(原字节数组[i]);
}
return 搜列集合.ToArray();
}
public void 创建文件File(string 路径, byte[] 欲写出的字节数组)
{
if (File.Exists(路径))
{
File.Delete(路径);
}
File.WriteAllBytes(路径, 欲写出的字节数组);
}
QQ:260987762

 
	
                                                 VIP会员
VIP会员 购物车
购物车


 私信
                         私信 
                     发表新帖
发表新帖 立即签到
立即签到 
        		  
        		 
         		 关注
关注
                  回复
 回复 支持(
                	支持( 反对(
                    反对( 
                







 
                     
                     
					 
						 
						 
						 
						