2 비트의 코드가 있습니다. 하나는 zip 파일을 업로드하고 하나는 업로드를 드라이브에 저장하는 서버입니다. 내 문제는 Windows 7 기본 zipping 프로그램에서 잘 열리는 zip 파일을 업로드하는 것입니다. 그러나 웹 서버에서 열려고 시도했을 때 오류가 더 이상 열리지 않습니다.Win 7 Zip 프로그램에서 더 이상 HTTP를 통한 Zip 파일 게시 안 함
Windows를 열 수 없습니다. 폴더. 압축 된 zipped 폴더 'blah'가 잘못되었습니다.
주 1 : 파일은 WinRar 또는 다른 zip 프로그램에서 완전히 열립니다.
주 2 : 원본 파일 및 서버의 파일을 디스크에 동일한 크기하지만 서버의 하나의 크기는 여기
업로드 참아 코드입니다 더 큰 200ish 바이트되어 있습니다 : 여기
public static String UploadFile(String url, String filePath)
{
if (!File.Exists(filePath))
throw new FileNotFoundException();
try
{
using (var client = new WebClient())
{
byte[] result = client.UploadFile(url, filePath);
UTF8Encoding enc = new UTF8Encoding();
string response = enc.GetString(result);
return response;
}
}
catch (WebException webException)
{
HttpWebResponse httpWebResponse = webException.Response as HttpWebResponse;
return (httpWebResponse == null) ? webException.Message : httpWebResponse.StatusCode.ToString();
}
}
들어오는 파일을 저장 (닷넷 C#을 aspx 페이지의 페이지로드에 존재) 서버의 코드입니다 :
private void SaveZipFile()
{
string fileName;
string zipPath;
fileName = GenerateFileName();
zipPath = _hhDescriptor.GetDirectory(path => Server.MapPath(("./" + _serviceName + "\\" + path)) + "\\" + fileName + ".zip");
if (!Directory.Exists(zipPath))
{
Directory.CreateDirectory(Path.GetDirectoryName(zipPath));
}
Request.SaveAs(zipPath, false);
logger.Trace(string.Format("ManualUpload: Successfully saved uploaded zip file to {0}", zipPath));
}
가능한 모든 아이디어/제안이 깨뜨릴 수 있습니다 크게 감사하겠습니다!. 아마 zip 파일과 함께 다른 임의의 물건을 저장하고 있습니다.
UPDATE 1 : 내가 메모장에서 서버의 zip 파일을 열 때
그것은 그래서 제 질문은 헤더 정보를 캡처하지 않고 우편을 저장하는 방법입니다
-----------------------8cd8d0e69a0670b Content-Disposition: form-data; name="file"; filename="filename.zip" Content-Type: application/octet-stream
가 포함되어 있습니다.
예, 귀하가 게시 한 시간에 답을 찾아 왔습니다. Request.Files [0] .SaveAs (zipPath); 그것을했다. 감사! –