Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out on what place on a harddisk a program / file is installed

Tags:

c#

windows

Let's say I have a file: test.txt and I save it on my harddisk.

Is there a way to determine on what (physical) spot the file is saved on the hard disk?

For example on vector 12 on track 10 of the hard disk.

I don't know if I got the terminology right of the above, but I hope you get what I mean.

I want to write of program wheer the user can point to a file and the program will find out where the file is on the HDD. Something like the old defrag (it's Windows ;) ) where it shows what parts of the disk is in use.

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

P.S. The client will be Windows 7 (so think NTFS if it matters).

like image 879
PeeHaa Avatar asked Nov 14 '22 11:11

PeeHaa


1 Answers

I'm pretty sure that doing that sort of low-level disk i/o in managed code is going to be...difficult, at best. Here's somebody that's done something like it:

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

Anything you write to do something like this has to be hardware-dependent: unless you know what hardware you're talking to, you've got no idea how it physically stores data (e.g., a USB memory stick has neither platters, tracks nor sectors, nor does it spin. Yet, for all intents and purposes, it appears to be a disk).

Normally, you'd write some sort of device driver to accomplish this. This link

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

might help.

like image 199
Nicholas Carey Avatar answered Nov 16 '22 04:11

Nicholas Carey