HttpPostedFile.SaveAs(String) 메서드

정의

업로드된 파일의 콘텐츠를 저장합니다.

public:
 void SaveAs(System::String ^ filename);
public void SaveAs (string filename);
member this.SaveAs : string -> unit
Public Sub SaveAs (filename As String)

매개 변수

filename
String

저장된 파일의 이름입니다.

예외

RequireRootedSaveAsPath 개체의 HttpRuntimeSection 속성이 true로 설정되지만 filename이 절대 경로가 아닌 경우

예제

다음 코드 예제에서는 웹 서버의 로컬 디스크에 C:\TempFiles 폴더 클라이언트에서 업로드 되는 모든 파일을 저장 하는 방법에 설명 합니다.

String TempFileName;
 HttpFileCollection MyFileCollection = Request.Files;

 for (int Loop1 = 0; Loop1 < MyFileCollection.Count; Loop1++)
 {
    // Create a new file name.
    TempFileName = "C:\\TempFiles\\File_" + Loop1.ToString();
    // Save the file.
    MyFileCollection[Loop1].SaveAs(TempFileName);
 }
Dim Loop1 As Integer
 Dim TempFileName As String
 Dim MyFileCollection As HttpFileCollection = Request.Files
 
 For Loop1 = 0 To MyFileCollection.Count - 1
    ' Create a new file name.
    TempFileName = "C:\TempFiles\File_" & CStr(Loop1)
    ' Save the file.
    MyFileCollection(Loop1).SaveAs(TempFileName)
 Next Loop1

설명

업로드 된 파일을 포함 하는 요청에 대해 허용 되는 최대 크기는 4MB를 기본적으로 됩니다. Machine.config 또는 Web.config 파일에서 최대 요청 크기를 지정할 수 있습니다 합니다 maxRequestLength 특성을 httpRuntime 요소 (ASP.NET 설정 스키마) 요소입니다. 사용 하 여 특정 페이지에 대 한 최대 요청 크기를 지정할 수 있습니다 합니다 location 요소 (ASP.NET 설정 스키마) Web.config 파일의 요소입니다.

적용 대상