Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

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.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

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

Navigation

Google Ads

ASP.NET: Files and Path information

From Wiki

Jump to: navigation, search


Summary: Files and Path information

Here's an example of some of the commonly used file and path information objects and methods:

  1. Dim f As New FileInfo("path to your file")
  2. Response.Write(f.Exists & " - Shows if the file exists<br/>")
  3. Response.Write(f.DirectoryName & " - The directory name of the file<br/>")
  4. Response.Write(f.FullName & " - The full path of the file<br/>")
  5. Response.Write(f.CreationTime & " - When the file was created<br/>")
  6. Response.Write(f.Name & " - The name of the file<br/>")
  7. Response.Write(f.Extension & " - The file extension<br/>")
  8.  
  9. Dim d As New DirectoryInfo("path to the directory")
  10. Response.Write(d.Exists & " - Shows if the directory exists<br/>")
  11. Response.Write(d.FullName & " - The full path of the directory<br/>")
  12. Response.Write(d.CreationTime & " - When the directory was created<br/>")
  13. Response.Write(d.Name & " - The name of the directory<br/>")
  14. Response.Write(d.GetDirectories.Length & " - Gets a count of sub directories <br/>")
  15. Response.Write(d.GetFiles.Length & " - Gets a count of files in the directory <br/>")

Note: You may need to add this Imports statement:

  1. Imports System.IO


This Hack is part of the ASP.NET Hacks collection

499 Rating: 2.3/5 (8 votes cast)