.NET Framework 2 용으로 만들어진 예제 1에 따라 프로그램을 만들었지 만 .NET Framework 3.5로 변환했습니다. 이 코드를 수정하여 어떻게 작동시켜야합니까? 어떻게하면 서버 측을 디버그 할 수 있습니까? 서버 측은 수동으로 매개 변수를 URL에 삽입 할 때 작동하므로 문제는 클라이언트 측 코드에 있어야합니다.WebClient가 IHttpHandler에 연결하지 않습니다.
private void UploadFile(string fileName, System.IO.Stream data)
{
UriBuilder ub = new UriBuilder("http://localhost:59491/receiver.ashx");
ub.Query = string.Format("filename={0}", fileName);
WebClient c = new WebClient();
c.OpenWriteCompleted += (sender, e) =>
{
PushData(data, e.Result);
e.Result.Close();
data.Close();
};
c.OpenWriteAsync(ub.Uri);
}
private void PushData(System.IO.Stream input, System.IO.Stream output)
{
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)
{
output.Write(buffer, 0, bytesRead);
}
}
1http://www.c-sharpcorner.com/UploadFile/nipuntomar/FileUploadsilverlight03182009030537AM/FileUploadsilverlight.aspx