我用string aa="44657374726f7920746865206372616e652e000044657374726f79207468652062617272656c732e"我想把这个string的值 保存为正常的十六进制文件C#怎么实现

解决方案 »

  1.   

    string 中的就是正常的十六进制
      

  2.   

    string aa="44657374726f7920746865206372616e652e000044657374726f79207468652062617272656c732e"
    应该是一个16进制的字符串吧,每两位表示一个16进制数,是吧?那你应该用一个循环,2位2位的取,然后把16进制转换为10进制,就得到了一个0-255之间的数字,把它转换成字节然后循环完毕会得到一个字节数组,写入一个文件,就可以了
      

  3.   

    string _ValueText = "44657374726f79207468652062617272656c732e";
      byte[] _ValueByte = new byte[_ValueText.Length / 2
      for (int i = 0; i != _ValueByte.Length; i++)
      {
      _ValueByte[i] = Convert.ToByte(_ValueText.Substring(i * 2, 2), 16);
      }
      string _Value = System.Text.Encoding.Default.GetString(_ValueByte);
      Console.Write(_Value);
    就是16
      

  4.   


    string str = "44657374726f7920746865206372616e652e000044657374726f79207468652062617272656c732e";
                byte[] by = new byte[str.Length / 2];
                for (int i = 0; i < by.Length; i++)
                {
                   string s= str.Substring(i*2, 2);
                   by[i] =(byte) Convert.ToInt32(s, 16);
                }
                System.IO.FileStream fs = new System.IO.FileStream("c:/aaa.txt", System.IO.FileMode.Create);
                fs.Write(by, 0, by.Length);
                fs.Close();
      

  5.   

                string aa="44657374726f7920746865206372616e652e000044657374726f79207468652062617272656c732e";            System.IO.File.WriteAllText(@"d:\1.txt", aa, System.Text.Encoding.Default);
      

  6.   

    是图片的话,你要知道它的扩展名(jpg还是gif什么的),然后存的时候也用一样的扩展名,就能实现图片的复制了把我例子里面 "aaa.txt" 改一下就可以了
      

  7.   

    将其读到System.IO.Streame流fs中(内存流,文件流等),然后构造一个空的System.Drawing.Image对象image,用image.FormStream( fs)方法从流中读取图片