DelphiFAQ Home Search:

Determine if a file resides on NTFS file system

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

Question::

I need to determine if a file is located on a NTFS formatted drive. There is no Windows API function for this.

Answer::

Indeed the Windows API does not provide such a function. Besides attempting to use NTFS specific functionalities and checking whether are supported - thus assuming it could be NTFS, you can create a FileSystemObject and use scripting.

The only downside of this attempt is that for security reasons scripting may be disabled on some computers.

uses
  ComObj;

function IsNTFS(aFilename: string) : boolean;
var
  fso,
  drv: OLEvariant;
begin { IsNTFS }
  IsNTFS := False; 
  fso := CreateOLEObject('Scripting.FileSystemObject'); 
  drv := fso.GetDrive(fso.GetDriveName(aFilename)); 
  IsNTFS := drv.FileSystem='NTFS' 
end; { IsNTFS }


// example
  if IsNTFS('f:\letter.doc') then
    ShowMessage('File resides on NTFS File System')
You don't like the formatting? Check out SourceCoder then!

Comments:

2007-04-13, 09:36:32
anonymous from United Kingdom  
There is a windows API call to do this

It also returns lots of other info about the partition

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Los Angeles, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.