Questions tagged «system.io.fileinfo»

2
将文件转换为Base64String然后再次返回
标题说明了一切: 我像这样读tar.gz档案 将文件分成字节数组 将这些字节转换为Base64字符串 将该Base64字符串转换回字节数组 将那些字节写回到新的tar.gz文件中 我可以确认两个文件的大小相同(以下方法返回true),但是我无法再提取副本版本。 我想念什么吗? Boolean MyMethod(){ using (StreamReader sr = new StreamReader("C:\...\file.tar.gz")) { String AsString = sr.ReadToEnd(); byte[] AsBytes = new byte[AsString.Length]; Buffer.BlockCopy(AsString.ToCharArray(), 0, AsBytes, 0, AsBytes.Length); String AsBase64String = Convert.ToBase64String(AsBytes); byte[] tempBytes = Convert.FromBase64String(AsBase64String); File.WriteAllBytes(@"C:\...\file_copy.tar.gz", tempBytes); } FileInfo orig = new FileInfo("C:\...\file.tar.gz"); FileInfo copy = …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.