Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
ASP.NET: Files and Path information
From Wiki
Summary: Files and Path information
Here's an example of some of the commonly used file and path information objects and methods:
- Dim f As New FileInfo("path to your file")
- Response.Write(f.Exists & " - Shows if the file exists<br/>")
- Response.Write(f.DirectoryName & " - The directory name of the file<br/>")
- Response.Write(f.FullName & " - The full path of the file<br/>")
- Response.Write(f.CreationTime & " - When the file was created<br/>")
- Response.Write(f.Name & " - The name of the file<br/>")
- Response.Write(f.Extension & " - The file extension<br/>")
- Dim d As New DirectoryInfo("path to the directory")
- Response.Write(d.Exists & " - Shows if the directory exists<br/>")
- Response.Write(d.FullName & " - The full path of the directory<br/>")
- Response.Write(d.CreationTime & " - When the directory was created<br/>")
- Response.Write(d.Name & " - The name of the directory<br/>")
- Response.Write(d.GetDirectories.Length & " - Gets a count of sub directories <br/>")
- Response.Write(d.GetFiles.Length & " - Gets a count of files in the directory <br/>")
Note: You may need to add this Imports statement:
- Imports System.IO
This Hack is part of the ASP.NET Hacks collection



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.