0
안녕하세요, WCF가 아닌 webservice에서 파일을 업로드하고 싶습니다. C#을 사용하고 웹 응용 프로그램에서 사용하고 있습니다. 웹 응용 프로그램에서 파일을 보내면 서비스에서 해당 파일 (텍스트 파일) 웹 사이트 또는 특정 위치의 업로드 폴더에 있습니다.asp.net webservice를 사용하여 파일 업로드
이 들어 나는이
같은 웹 서비스 만든 : 웹 서비스
를 만들기위한만든 빈 웹 응용 프로그램 -> 선택 새 항목 -> 웹 서비스
웹 서비스 코드 다음1> 쓴
public System.IO.Stream FileByteStream;
[WebMethod]
public void UploadFile()
{
FileStream targetStream = null;
Stream sourceStream = FileByteStream;
string uploadFolder = @"D:\UploadFile";
string filePath = Path.Combine(uploadFolder, @"C:\Users\maya\Desktop\test.txt");
using (targetStream = new FileStream(filePath, FileMode.Create,
FileAccess.Write, FileShare.None))
{
//read from the input stream in 65000 byte chunks
const int bufferLen = 65000;
byte[] buffer = new byte[bufferLen];
int count = 0;
while ((count = sourceStream.Read(buffer, 0, bufferLen)) > 0)
{
// save to output stream
targetStream.Write(buffer, 0, count);
}
targetStream.Close();
sourceStream.Close();
}
내 입력이 없습니다. 수동으로 한 텍스트 파일을 입력했습니다. 해당 파일을 uploadfolder로 전송하고 싶습니다. 이 라인에서
HTTP 500 Internal server error
:이 오류를 얻고있다
while ((count = sourceStream.Read(buffer, 0, bufferLen)) > 0)
어떻게이 문제를 처리하기 위해?