Login or Sign Up to become a member!

EXPERTS, INFORMATION, IDEAS & KNOWLEDGE

Social bookmarker Add this

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: 0.0/5 (0 votes cast)