Opt In (Do Not Edit Here)

May 12, 2011

FileSystemObject - Drive Object


1.     First we have to declare four variables.

     Dim FSO, Drive, AllDrive, type

2.    Now create an instance of FileSystemObject and access all the available drives in computer.
           
      FSO = Server.CreateObject("Scripting.FileSystemObject")

     AllDrive = FSO.Drives

3.    Now display the Information for each drive

     Response.Write("Demo - Drive Object ")
    
For Each Drive In AllDrive

Response.Write("")
        Response.Write("Drive Letter :"+ Drive.DriveLetter()+"")
Response.Write("Path :  " + Drive.Path())
Response.Write("IsReady : " + Drive.IsReady().ToString)

   If Drive.IsReady Then   'To Retrieve the Type of Drive
      Response.Write("Drive Type : ")
      Select Case Drive.DriveType()
      'Property DriveType() Returns a Value indicating
      'the Type of a Specified Srive.
          Case 0 : type = "Unknown"
                   Response.Write(type)
          Case 1 : type = "Removable"
                   Response.Write(type)
          Case 2 : type = "Fixed"
                   Response.Write(type)
          Case 3 : type = "Network"
                   Response.Write(type)
          Case 4 : type = "CD-ROM"
                   Response.Write(type)
          Case 5 : type = "RAM Disk"
                   Response.Write(type)
      End Select

      'To Retrieve the Name of the Drive
      Response.Write("Volume Name : " + Drive.VolumeName)

      'To Retrieve the Type of File System
      Response.Write("File System : " + Drive.FileSystem)

      'To Retrieve the Total of the Specified Drive in GigaByte(GB)
      'The Division by(1024*1024*1024) to the Specified Property
      'is Done to get the Size of specified Drive in GigaByte
      Response.Write("Total Size : " + (Drive.TotalSize() / (1024 * 1024 * 1024)).ToString + " GigaByte")

      'The value returned by the FreeSpace property is typically         'the same as that returned the AvailableSpace property.              'Differences may occur between the two for
      'computer systems that support quotas.
      Response.Write("Free Space : " + (Drive.FreeSpace() /(1024 * 1024 * 1024)).ToString + " GigaByte")
      Response.Write("Available Space : "+(Drive.AvailableSpace() / (1024 * 1024 * 1024)).ToString + " GigaByte")

       'To Retrieve the Serial Number(in Hex) of 
       'the Specified Drive
        Response.Write("Drive Serial Number : " + Hex(Drive.SerialNumber))
    End If
Next

4.    The Output will be as follows…..



About The Author :

Freelancer and IT Engineer
Softwares Developed by Mayur Dighe ImmortalDotNet.WordPress.com

0 comments :

All Rights Reserved. 2014 Copyright SIMPLITONA

Powered By Blogger | Published By Gooyaabi Templates Designed By : BloggerMotion

Top