如题,^_^

解决方案 »

  1.   

    你是不是要把图片保存进XML文件啊,如果是给你个源码
    http://download.csdn.net/source/617737
      

  2.   

    干吗非要放到xml中啊,byte有好多不可显示的字符.
    直接用2进制流写到文件中即可.public static void WriteAllBytes(
    string path,
    byte[] bytes
    )
    public static byte[] ReadAllBytes(
    string path
    )
      

  3.   

    参考一下
    http://www.zzchn.com/edu/20080220/80290.shtml
      

  4.   

    先做encode to base64,变成可显示字符,保存。
    读出后,再uncode base64.
    使用System.Convert中的函数
    public static string ToBase64String( byte[] inArray)
    public static byte[] FromBase64String( string s)public void EncodeWithString() {
    System.IO.FileStream inFile; 
    byte[]  binaryData; try {
    inFile = new System.IO.FileStream(inputFileName,
      System.IO.FileMode.Open,
      System.IO.FileAccess.Read);
    binaryData = new Byte[inFile.Length];
    long bytesRead = inFile.Read(binaryData, 0,
    (int)inFile.Length);
    inFile.Close();
    }
    catch (System.Exception exp) {
    // Error creating stream or reading from it.
    System.Console.WriteLine("{0}", exp.Message);
    return;
    } // Convert the binary input into Base64 UUEncoded output.
    string base64String;
    try {
     base64String = 
    System.Convert.ToBase64String(binaryData, 
      0,
      binaryData.Length);
    }
    catch (System.ArgumentNullException) {
    System.Console.WriteLine("Binary data array is null.");
    return;
    } // Write the UUEncoded version to the output file.
    System.IO.StreamWriter outFile; 
    try {
    outFile = new System.IO.StreamWriter(outputFileName,
    false,
    System.Text.Encoding.ASCII);  
    outFile.Write(base64String);
    outFile.Close();
    }
    catch (System.Exception exp) {
    // Error creating stream or writing to it.
    System.Console.WriteLine("{0}", exp.Message);
    }
    }
    public void DecodeWithString() {
    System.IO.StreamReader inFile; 
    string base64String; try {
    char[] base64CharArray;
    inFile = new System.IO.StreamReader(inputFileName,
    System.Text.Encoding.ASCII);
    base64CharArray = new char[inFile.BaseStream.Length];
    inFile.Read(base64CharArray, 0, (int)inFile.BaseStream.Length);
    base64String = new string(base64CharArray);
    }
    catch (System.Exception exp) {
    // Error creating stream or reading from it.
    System.Console.WriteLine("{0}", exp.Message);
    return;
    } // Convert the Base64 UUEncoded input into binary output.
    byte[] binaryData;
    try {
    binaryData = 
    System.Convert.FromBase64String(base64String);
    }
    catch (System.ArgumentNullException) {
    System.Console.WriteLine("Base 64 string is null.");
    return;
    }
    catch (System.FormatException) {
    System.Console.WriteLine("Base 64 string length is not " +
    "4 or is not an even multiple of 4." );
    return;
    } // Write out the decoded data.
    System.IO.FileStream outFile;
    try {
    outFile = new System.IO.FileStream(outputFileName,
       System.IO.FileMode.Create,
       System.IO.FileAccess.Write);
    outFile.Write(binaryData, 0, binaryData.Length);
    outFile.Close();
    }
    catch (System.Exception exp) {
    // Error creating stream or writing to it.
    System.Console.WriteLine("{0}", exp.Message);
    }
    }
      

  5.   

    把byte[]转为base64string保存为文本格式就可以了