克服Gmail附件阻止
本文关键字:Gmail 克服 | 更新日期: 2023-09-27 18:34:49
我已经通过gmail向某人发送了一些rar-red可执行文件,现在我什至无法下载自己的附件。我得到:
Anti-virus warning - 1 attachment contains a virus or blocked file. Downloading this attachment is disabled.
我发现了这个并尝试在 C# 中实现相同的内容:
private static void Main(string[] args)
{
var encodedString = System.IO.File.ReadAllText(@"D:'original.txt");
var decodedString = Base64Decode(encodedString);
var file = new System.IO.StreamWriter("d:''result.rar");
file.WriteLine(decodedString);
file.Close();
}
public static string Base64Decode(string base64EncodedData)
{
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
不幸的是,生成的 rar 文件无法解冻(D:''result.rar:存档意外结束(。我解码数据的方式有问题吗?我也不是百分百确定将哪些数据放入原始数据.txt。
我最初发送的电子邮件看起来像这样(其中...表示未显示数据以保持此帖子简短(:
...
--047d7b2e141ddd6f7e04ff5a46b7--
--047d7b2e141ddd6fd404ff5a46b9
Content-Type: application/rar; name="Bla.rar"
Content-Disposition: attachment; filename="Bla.rar"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_hy7mvnnm0
UmFyIRoHAM+QcwAADQAAAAAAAADyjXSAgCsAPD8BAO9bCQACZPAbLMVLsj4dMwsAIAAAAHhtbDJi
aWIuZXhlGAHRGQyJJhwSInMkmEkCQzAZBw4pgMAgIjAeMOKyLMXBZNYoQDUBBQRHiIjmHB05MkUx
...
cjR8qjjxbcI0s1b0SW86worLTu1860ysaZspuo8IlJZtnBtamJHLdGdp9YTcfkhsrnCba4l8o3oN
RiJTNE614Lb7GdfvySstNFD1eyVx1gexl8lax6hwn/8gxD17AEAHAA==
--047d7b2e141ddd6fd404ff5a46b9--
我已将其用作我的数据:
UmFyIRoHAM+QcwAADQAAAAAAAADyjXSAgCsAPD8BAO9bCQACZPAbLMVLsj4dMwsAIAAAAHhtbDJi
aWIuZXhlGAHRGQyJJhwSInMkmEkCQzAZBw4pgMAgIjAeMOKyLMXBZNYoQDUBBQRHiIjmHB05MkUx
...
cjR8qjjxbcI0s1b0SW86worLTu1860ysaZspuo8IlJZtnBtamJHLdGdp9YTcfkhsrnCba4l8o3oN
RiJTNE614Lb7GdfvySstNFD1eyVx1gexl8lax6hwn/8gxD17AEAHAA==
这是对的吗?
附注:
我选择的数据是正确的,我已经回答了我的问题。希望这将在未来对某人有所帮助。
试试这个:
private static void Main(string[] args)
{
var encodedString = System.IO.File.ReadAllText(@"D:'original.txt");
var bytes = System.Convert.FromBase64String(encodedString);
System.IO.File.WriteAllBytes("d:''result.rar", bytes);
}
在安卓设备上使用 Gmail 应用下载文档。 然后将设备连接到笔记本电脑,将文件从Android设备传输到笔记本电脑。
这里采用的DecodeWithString((可以解决问题。希望这将在未来对某人有所帮助。
附注:
这是代码:
public void DecodeWithString() {
System.IO.StreamReader inFile;
string base64String;
try {
char[] base64CharArray;
inFile = new System.IO.StreamReader(@"D:'original.txt",
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("d:''result.rar",
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);
}
}