0
我有在網絡中發送的壓縮文件的問題。所有其他格式的我能夠除了.zip文件發送..幫助:zip文件流
我嘗試了很多我不就沒怎麼做..代碼我寫在客戶端上傳文件,這是微軟建議這裏是link
我能夠創建zip文件,如果我試圖打開它說損壞..文件的大小也不盡相同。
這裏是代碼
public void UploadFile(string localFile, string uploadUrl)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uploadUrl);
req.Method = "PUT";
req.AllowWriteStreamBuffering = true;
// Retrieve request stream and wrap in StreamWriter
Stream reqStream = req.GetRequestStream();
StreamWriter wrtr = new StreamWriter(reqStream);
// Open the local file
Stream Stream = File.Open(localFile, FileMode.Open);
// loop through the local file reading each line
// and writing to the request stream buffer
byte[] buff = new byte[1024];
int bytesRead;
while ((bytesRead = Stream.Read(buff, 0,1024)) > 0)
{
wrtr.Write(buff);
}
Stream.Close();
wrtr.Close();
try
{
req.GetResponse();
}
catch(Exception ee)
{
}
reqStream.Close();
請幫我...
感謝
是......你是對的... 謝謝非常感謝很多人.. – Naruto 2009-11-20 07:19:09