Working with File and Directory Properties, Attributes and Access Control List
page 2 of 7
by SANJIT SIL
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 40691/ 78

Properties and Attributes

Files and Directories share certain properties that we can use to determine the created date of a file or directory, size, last modified date, attributes, the extension of file, etc.  These properties can be viewed by opening the file’s Properties dialog.  We can open this dialog from windows explorer by either right clicking on the file and selecting Properties from the context menu or selecting Properties from file menu.  Using both FileInfo and DirectoryInfo classes we can access the properties and modify them.  In Listing 1 the properties of a file have been accessed programmatically.

Listing 1

private void show()
{
  FileInfo file = new FileInfo("C:/Documents and Settings/SanjitSil/Test.txt");
  Response.Write("Location :" + file.FullName + "<BR>" + "Size :" + file.Length
    + "<BR>" + "Created :" + file.CreationTime + "<BR>" +
    "Modified :    file.LastWriteTime + "<BR>" + "Accessed :
    " + file.LastAccessTime + "<BR>" + "Attributes :" + file.Attributes + "<BR>
    " + "Extension :" + file.Extension + "<BR>");
 
}

In the above specified code a text file has been taken.  Each time we edit the file, the value of the properties of the file will be getting changed.  For more information on File, Directory, FileInfo and DirectoryInfo classes, readers may read my earlier article entitled “Working with Files and Directories.”


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-23 4:14:40 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search