low level file system access to ntfs volumes... in .net?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi all, hope you can help me with this question i've been scouring the net
for a couple of days now :-(.
is there any way to access the logical blocks on an ntfs volume from within
..NET? i'm thinking about starting a disk defragger project and want to know
where to get started. of course i have a long way to go before i can move
blocks around and end up with a drive that still has valid NTFS data on it
:-) but i want to at least confirm that i can do this much before investing
any more time.
if there's a way to do it using interop or calling platform (non .NET) code
i'm all ears as well, basically i can't even find how to access file system
stuff in anything but C, which doesn't help me much unless someone can give
me an example of how to use it.
thanks in advance for any help,
Aaron
 
Aaron,

There is no native way to do this in .NET. Rather, you will have to
call Windows API methods to access the drive. If you list the APIs that you
want to call, we can easily translate them to their .NET declarations, which
you could then call in a similar (most likely) manner than you would in C
(with some changes, of course).
 
On Mon, 25 Oct 2004 06:29:04 -0700, Aaron Oxford <Aaron
hi all, hope you can help me with this question i've been scouring the net
for a couple of days now :-(.
is there any way to access the logical blocks on an ntfs volume from within
.NET? i'm thinking about starting a disk defragger project and want to know
where to get started. of course i have a long way to go before i can move
blocks around and end up with a drive that still has valid NTFS data on it
:-) but i want to at least confirm that i can do this much before investing
any more time.
if there's a way to do it using interop or calling platform (non .NET) code
i'm all ears as well, basically i can't even find how to access file system
stuff in anything but C, which doesn't help me much unless someone can give
me an example of how to use it.
thanks in advance for any help,
Aaron

Defragging is (relatively) simple. The APIs exposed prevent any damage
from being done. See
http://blogs.msdn.com/jeffrey_wall/archive/2004/09/13/229137.aspx for
a C# wrapper for the Defrag APIs.

Austin
 
Thanks, both replies were swift and helpful. I believe I can get started with
this, at least enough to break a drive or two :-)

One last thing though, if someone could point me to the documentation on the
Windows APIs that guy's wrapper is calling it would help me understand what
I'm doing. I've been searching blind up to this point, not knowing what to
type into google or whatever. Even just name for the component of Windows
this is part of or the API being used would be almost as helpful as the
documents themselves.

Again thank you, I've never had such timely and to-the-point replies on any
forum, newsgroup, mailing list, you name it (experts-exchange.com - get outta
here!). I think I will begin to frequent this list and will even try to shed
some light on the areas of .NET I've played with. I'm loving the new language
and API so much that I'm dabbling with things all over the place - right now
I've got a little app checking to see if I have any duplicate pictures in my
porn collection, and once that's finished running it will be time to get back
into the DVD->WMV ripper. I guess Microsoft probably didn't have this sort of
thing in mind when they invented a whole new application framework but hey,
cheers to them and I'm learning APIs fast! Maybe I'll write something useful
one day. :-)

Aaron.
 
Back
Top