Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Apr 7, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Determine the File System Type

With the advent of the FAT32 file system, you might want to use VB to determine the type of file system being used for a particular drive. This example is set for the C drive; change the variable sDrive to test other drives. Run this routine; the variable sResult contains the file system name string:
Private Declare Function GetVolumeInformation _
	Lib "kernel32" Alias "GetVolumeInformationA" _
	(ByVal lpRootPathName As String, ByVal _
	lpVolumeNameBuffer As String, ByVal _
	nVolumeNameSize As Long, _
	lpVolumeSerialNumber As Long, _
	lpMaximumComponentLength As Long, _
	lpFileSystemFlags As Long, ByVal _
	lpFileSystemNameBuffer As String, ByVal _
	nFileSystemNameSize As Long) As Long
Public Function WhichFileSystem(ByVal Drive _
	As String) As String
	Dim sVolBuf As String * 255
	Dim sSysName As String * 255
	Dim lSerialNum As Long
	Dim lSysFlags As Long
	Dim lComponentLength As Long
	Dim lRes As Long
	lRes = GetVolumeInformation(Drive, sVolBuf, _
		255, lSerialNum, lComponentLength, _
		lSysFlags, sSysName, 255)
	If lRes Then
		WhichFileSystem = Left$(sSysName, _
			InStr(sSysName, Chr$(0)) - 1)
		WhichFileSystem = "<unknown>"
	End If
End Function
Dan Verkade
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date