string与byte[]转换(通过Encoding类)
string src = "abcd1234"; byte[] types=Encoding.Default.GetBytes(src); string dest= Encoding.Default.GetString(types);
读取Assembly中的文本
byte[] pubArray = AssemblyTextReader.Read("NS.AssemblyName.dir1.subdir.file"); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); Stream ms = assembly.GetManifestResourceStream("NS.AssemblyName.dir1.subdir.file");
byte[]与Stream转换
byte[] bytes=.... MemoryStream ms = new MemoryStream(bytes); byte[] dst=ms.toArray();
文件与流
FileStream steram=new FileStream("file.txt",FileMode.Create); BinaryWriter bw = new BinaryWriter(stream); bw.Write(bytes)
byte[]与Base64字符串转换(Base64编解码)
string base64str=Convert.ToBase64String(byte[] bytes); byte[] bytes=Convert.FromBase64String(base64str);
时间: 2024-10-27 04:59:32