Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 克服gmails连接阻塞_C#_.net - Fatal编程技术网

C# 克服gmails连接阻塞

C# 克服gmails连接阻塞,c#,.net,C#,.net,我已经通过gmail向某人发送了一些rar red可执行文件,现在我甚至无法下载自己的附件。我得到: Anti-virus warning - 1 attachment contains a virus or blocked file. Downloading this attachment is disabled. 我发现并尝试在C#中实现同样的功能: 不幸的是,结果rar文件无法取消共享(D:\result.rar:意外的归档结束)。我解码数据的方式有问题吗?我也不能百分之百确定要将哪些数

我已经通过gmail向某人发送了一些rar red可执行文件,现在我甚至无法下载自己的附件。我得到:

Anti-virus warning - 1 attachment contains a virus or blocked file. Downloading this attachment is disabled.
我发现并尝试在C#中实现同样的功能:

不幸的是,结果rar文件无法取消共享(D:\result.rar:意外的归档结束)。我解码数据的方式有问题吗?我也不能百分之百确定要将哪些数据放入original.txt

我最初发送的电子邮件如下所示(其中…表示未显示数据以保持此帖子简短):

我已将此用作我的数据:

UmFyIRoHAM+QcwAADQAAAAAAAADyjXSAgCsAPD8BAO9bCQACZPAbLMVLsj4dMwsAIAAAAHhtbDJi
aWIuZXhlGAHRGQyJJhwSInMkmEkCQzAZBw4pgMAgIjAeMOKyLMXBZNYoQDUBBQRHiIjmHB05MkUx
...
cjR8qjjxbcI0s1b0SW86worLTu1860ysaZspuo8IlJZtnBtamJHLdGdp9YTcfkhsrnCba4l8o3oN
RiJTNE614Lb7GdfvySstNFD1eyVx1gexl8lax6hwn/8gxD17AEAHAA==
这是正确的吗

附言:

我选择的数据是正确的,我已经回答了我的问题。希望这将有助于未来的人

形式为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);
   }
}
请尝试以下方法:

    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);
    }

在Android设备上使用Gmail应用程序下载文档。然后将设备连接到笔记本电脑,将文件从Android设备传输到笔记本电脑

如果你投了反对票,说为什么。。。我认为这个问题没有错。
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);
   }
}
    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);
    }