Forcing a File to be Unmovable in Disk.
Hello Gurus,
I want one of my files to be always unmovable in disk. For instance i create a 80 MB file and mark it as System,Readonly and Hidden. I make it as a contiguos file (on the disk as contiguos sectors) by using the Defrag APIs. Now my only other objective is to make this file unmovable on the disk. Windows XP provides an interesting DeviceIOControl of FSCTL_MARK_HANDLE with MARK_HANDLE_INFO. This would make the File clusters locked so that any Defrag process will not be able to move the file on the disk. However this works only in NTFS as the Structure is valid only for NTFS. Also This is not at all applicable in Windows 2000.
How to make a file unmovable by any Defrag processes in Windows 2000 as well as FAT Systems.
One of sugested tips was open a file for exclusive access and defrag will not be able to move it. But unfortunately that does not work.
Any tips guys??
Thanks and Regards
Kandukondein.
Re: Forcing a File to be Unmovable in Disk.
I don't think there is a solution that would work on FAT systems.
If the FAT system doesn't have the appropriate iocontrols, simply opening and locking the file won't work, because FAT drives don't need to be defragged from within Windows. Some defrag utilities might defrag drives at the boot screen of Windows, as such bypassing any running application.
PS: why is so important that the file is unmovable?
Re: Forcing a File to be Unmovable in Disk.
Thanks mark . I have our proprietery file at one portion in the hard disk where i maintain some Boot Info. That file is actually encrypted which i can read it before the boot process begins. I cannot have that file moved from that specific portion in the harddisk. If the file moves then that wud cause huge problems. I have that solved in Windows XP with MARK_INFO_HANDLE and doing a DevIOControl. But this is not applicable in Win 2000. I dont worry abt FAT File Systems. Is there any way can it be done in Win 2000. MArking a file exclusively and locking seems NOT to work in Win 2000. Right now I just have to prevent it from stupid Windows Defrag. :-((( Even though i mark the file as SYSTEM,READONLY AND HIDDEN it still gets moved in Windows 2000. But MS declares that files marked as System are unmovable files. I wish there is a way to deal with this situation in 2000.
Is there any way?