System.Web Namespace HttpPostedFile Class
Saves an uploaded MIME message body to a file on the server.
[ VB ]
Public Sub SaveAs ( _
ByVal filename As String _
)
[ C# ]
public void SaveAs (
string filename
);
[ C++ ]
public: void SaveAs (
String* filename
);
[ JScript ]
public function SaveAs (
filename : String
);
- filename
- The name of the file.
The following example saves all the files uploaded by the client to a folder named "C:\TempFiles" on the Web server's local disk.
[ VB ]
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
[ C# ]
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 );
}
HttpPostedFile Members HttpFileCollection Class