Find out where the program / file is installed on the hard disk

Say I have a file: test.txtand I save it to my hard drive.

Is there a way to determine where (physical) the file is stored on the hard drive?

For example, to vector 12 on track 10 of the hard drive.

I don’t know if I got the right to the terminology above, but I hope that you understand what I mean.

I want to write a program so that the user can point to a file, and the program will find out where the file is located on the hard drive. Something like old defragmentation (this is Windows;)) where it shows which parts of the disk are used.

What is it called and can it be achieved? (I'm not looking for code (although exmaples are ok, but rather it's possible)

PS The client will be Windows 7 (so think about NTFS, if that matters).

+5
source share
3 answers

I'm sure that executing this type of low-level drive in managed code will be ... complicated at best. Here is someone who has done something like this:

http://codebrainz.ca/index.php/2010/05/23/low-level-disk-io-in-managed-net/

Everything you write to do something like this should be hardware dependent: if you don’t know what hardware you are talking to, you don’t know how it physically stores the data (for example, there is no USB records, tracks and sectors, and also does not rotate. However, for all purposes and tasks it is a disk).

As a rule, for this you need to write some kind of device driver. This link

http://en.wikibooks.org/wiki/Windows_Programming/Device_Driver_Introduction

.

+1

Jeffrey Wall WebLog Defrag API # wrappers. GetFileMap sems , .

0

This is possible from C ++, so with a few questions you should be fine. See the FSCTL_GET_RETRIEVAL_POINTERS on MSDN to get started.

0
source

All Articles