HttpPostedFile.SaveAs(String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
업로드된 파일의 내용을 저장합니다.
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입니다. 최대 요청 크기는 maxRequestLength 요소의 특성의 Machine.config 또는 Web.config 파일에 지정할 수 있습니다. 특정 페이지에 대한 최대 요청 크기는 Web.config 파일의 location 요소(ASP.NET 설정 스키마) 요소를 사용하여 지정할 수 있습니다.