Some time you want to get directory information like sub directories , last access time , last write time , Create new directory in to parent directory
etc... programmatically using .Net.
You can get this information using "DirectoryInfo" class.
"DirectoryInfo" class available in System.IO Namespace.
There is one GetDirectories() method to get information about this.
Syntax :
Here strDirectoryPath is relative path of directory for which you want to get information
Here are one example which get all directories information of given directory path
You can get this information using "DirectoryInfo" class.
"DirectoryInfo" class available in System.IO Namespace.
There is one GetDirectories() method to get information about this.
Syntax :
System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(string strDirectoryPath);
Here strDirectoryPath is relative path of directory for which you want to get information
Here are one example which get all directories information of given directory path
System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo("c:\\");
//Here you can also specify path like "c:\\temp\\" to get information of temp directory
foreach (System.IO.DirectoryInfo objDirectory in directory.GetDirectories())
{
Response.Write("</br>Directory Name : " + objDirectory.Name);
Response.Write("</br>Last Access Time : " + objDirectory.LastAccessTime);
Response.Write("</br>Last Write Time : " + objDirectory.LastWriteTime);
}
//Here you can also specify path like "c:\\temp\\" to get information of temp directory
foreach (System.IO.DirectoryInfo objDirectory in directory.GetDirectories())
{
Response.Write("</br>Directory Name : " + objDirectory.Name);
Response.Write("</br>Last Access Time : " + objDirectory.LastAccessTime);
Response.Write("</br>Last Write Time : " + objDirectory.LastWriteTime);
}
Hi Rahul,
ReplyDeleteThank you for a good advice.
I have plan for this but this will take some time.