[파일업로드]
어플리케이션에서 웹서버로 파일전송하기~
app 프로그램 코드
try
{
string stringUrl="http://localhost/FileUpload/Upload.aspx";
System.Net.WebClient webClient = new System.Net.WebClient();
byte[] responseArray =webClient.UploadFile(stringUrl , "POST", this.label1.Text);
/*
System.Text.Encoding.ASCII.GetString(responseArray); 를 실행하면 파일 업로드한 웹페이지를 받아옵니다. 그러타면... 중복파일이 있다면 중복처리를 한다음에 변경된 파일 네임을 돌려주면 되겠따;;;
# System.Text.Encoding.ASCII.GetString(responseArray); 어라 한글깨졌네
아래처럼하니깐 한글이 안깨진다
this.textBox1.Text = System.Text.UTF8Encoding.UTF8.GetString(responseArray);
*/
this.label2.Text = System.Text.Encoding.ASCII.GetString(responseArray);
}
catch(System.Exception error)
{
MessageBox.Show( error.ToString() );
}
http://localhost/FileUpload/Upload.aspx코드
private void Page_Load(object sender, System.EventArgs e)
{
// 여기에 사용자 코드를 배치하여 페이지를 초기화합니다.
foreach(string f in Request.Files.AllKeys)
{
HttpPostedFile file = Request.Files[f];
file.SaveAs(@"C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\GenealogicalWEBSITE\FileUpload\" + file.FileName);
}
}
'C#.NET 네트워크' 카테고리의 다른 글
naver SMTP 보내기 오류 / 인증오류 (0) | 2019.09.09 |
---|---|
[WcfDataService WebClient FileUpload ]데이터서비스 파일 업로드하기 (1) | 2011.01.24 |
[Thread , ProgressBar] 스레드안에서 컨트롤에 접근하기 (0) | 2010.02.02 |
폼에 있는 콘크롤들은 폼이 사용하고 있는 스레드에서만 접근이 가능합니다 (0) | 2010.01.04 |