2012-06-21 35 views
0

我有一封電子郵件,附件是一個zip文件。出於某種原因,電子郵件客戶端並未將其作爲單獨的文件附加,只是將其作爲文本呈現在電子郵件中。沒有其他的壓縮文件副本。我試圖恢復它,但不知道它是否可能。電子郵件在文本中顯示這樣的文件;文件格式問題(明文)

>Content-Type: application/x-zip-compressed; name="me.zip"; 
> 
>Content-Disposition: attachment; filename="me.zip" 
> 
>Content-Transfer-Encoding: base64 
> 
> 
> 
>UEsDBBQAAQAIANeV9y5y6d5oG..... etc. 

它只是繼續隨機字母的年齡。有誰知道是否有可能恢復這樣的文件?

感謝您的指點。

+0

我只想問的人再次發送ZIP ...正確。 – 2012-06-21 23:13:15

+0

創建一個空的.txt文件,粘貼UEsD ...文本。將文件重命名爲.zip並查看它是否有效?我不知道,但我會給它一個去。 – blitzen

回答

0

我用這裏的代碼來解決這個問題。在線base64解碼器不工作,但它通過這段代碼工作。只需複製並粘貼,不需要任何修改;

http://msdn.microsoft.com/en-us/library/system.convert.frombase64string%28v=vs.110%29.aspx

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

這是一個base64編碼文件,你可以簡單地解碼base64編碼的字符並將結果輸出到一個文件(由於它是加密的,所以看起來更奇怪,這將是二進制數據)。

線索在Content-Transfer-Encoding標題中。

+0

那麼zip文件被加密 - 所以你說我可以解碼這個,然後輸出到一個文件,並重命名爲.zip? – creatiive

+0

@creative理論上,是的,你會這樣做。 –

+0

我將文本複製到網站http://www.base64decode.org/。然後我複製翻譯並將其保存爲文本文件,然後將其重命名爲.zip。你可以看到base64解碼似乎已經工作,因爲看文本,壓縮文件名在那裏看!但是,當我嘗試打開拉鍊時,它說「意想不到的結局」。現在感覺如此接近,因爲我可以看到文件名......但也許我錯過了文件中的一些結束字符? – creatiive