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


