asp.net gets the file attributes (retrieving file information in ASP) in asp.net. NET)
by Steven Smith
With asp.net we can easily get information about the file, including file name, path, extension, size and creation, and date of use. Next, we'll take a piece of code to see how to get information about the file.
If we use a typical ASP to get file information, it must be used. Filesystemobjiect the Script object to query for information about the file. But in ASP.net,. FileSystemObject is replaced by the System.IO namespace, in. System.IO, which contains a lot of classes to get file system information. One of these is FileInfo, which has information about the file that we want to know at all times. Using this class (object in the original text), we can completely get a lot of information about the file (here we use the file itself). You can also use FileInfo to perform other operations on the file, such as backup, renaming, and so on.
This code is very shallow, it is easy to see. First we assign the path of the file (fileinfo.aspx) to the variable filename, and the next step is to create the Objfi object and get the attributes we need. By doing so, all public properties of the FileInfo class can be manipulated by us, including the following properties:
Creation date, path, extension, full name, last access time, modified time, size (bytes), filename
In this way, we can assign the properties of the file to the text of the label control and display them.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service