ASP.NET.in.a.Nutshell.Second.Edition [Electronic resources]

G. andrew Duthie; matthew Macdonald

نسخه متنی -صفحه : 873/ 160
نمايش فراداده

HttpPostedFile

System.Web (system.web.dll)sealed class

The HttpPostedFile class allows you to easily manipulate files that are uploaded by the client. An HttpPostedFile instance is provided by the PostedFile property of the System.Web.UI.HtmlControls.HtmlInputFile control.

You can use the SaveAs( ) method to save a posted file to disk synchronously. The method will return once the file is completely uploaded. Alternatively, you can get a System.IO.Stream object containing the file from the InputStream property and use it to work with the file asynchronously (while it is being uploaded).

public sealed class 

HttpPostedFile { // Public Instance Properties public int

ContentLength {get; } public string

ContentType {get; } public string

FileName {get; } public Stream

InputStream {get; } // Public Instance Methods public void

SaveAs (string

filename ); }

Returned By

HttpFileCollection.{Get( ), this}, System.Web.UI.HtmlControls.HtmlInputFile.PostedFile