3

当我对我的 XP 机器进行碎片整理时,我注意到有一块“不可移动文件”。是否有文件属性可用于使我自己的文件不可移动?

澄清一下,我想要一种以编程方式告诉 Windows 我创建的文件应该是不可移动的方法。这可能吗,如果可以,我该怎么做?

谢谢,

特里

4

9 回答 9

9

A lot of system files cannot be moved after the system boots, such as the page file and registry database files.

This utility runs before Windows boots to defragment those files. I have it set to run at every boot, and it works well for me on several machines.

请注意,第一次启动并运行此实用程序时,碎片整理可能需要几分钟时间。不过,在第一次运行之后,它只需 3 或 4 秒即可完成。

Edit0:为了回应您的澄清-该链接表示 Windows 已将页面文件和注册表文件标记为打开以供独占访问。因此,您应该能够使用LockFile API 调用来做同样的事情。但是,这不是文件本身的属性。您必须实际运行一些后台程序来锁定文件以进行独占访问。

于 2008-09-09T15:38:59.993 回答
2

There are no file attributes that you can place on your files to mark them as immovable. The only way that a file cannot be moved (I think) during defragmentation is to have some other process have the file open (for read or write, I'm not even sure that you need to have the file open in exclusive mode or not).

坦率地说,我想不出你不希望你的文件移动的原因,除非你对你的文件在磁盘盘片上的位置有特定的要求。碎片整理通常会导致更快的磁盘访问,这似乎在所有情况下都是可取的:-)

于 2008-09-09T18:14:51.023 回答
1

This usually means that the file is in use by some process. If you're defragmenting, you'll likely see this with a lot of system files. If the file should legitimately be movable and is stuck (it's being held by a process that runs at startup but shouldn't be, for example), the most useful way of resolving the problem is to remove all permissions on the file, reboot, restore the permissions, and then get rid of the file/run the program that's trying to use it.

于 2008-09-09T15:36:29.953 回答
1

我想丑陋的方法是在启动时启动应用程序,每隔几秒钟检查一次碎片整理是否正在运行,如果是,则以独占模式打开文件。

这真的很难看,除非没有更清洁的解决方案,否则我不推荐它。

于 2008-09-09T15:48:45.527 回答
1

特里,答案都提到了防止文件在碎片整理期间变得不可移动的方法。从您的问题看来,您实际上是想让您的个人文件无法移动。您能否澄清一下使您的文件无法移动的吸引力。

于 2008-09-09T15:49:23.650 回答
0

我假设您使用的是 Windows 附带的碎片整理程序。一些像 DiskKeeper 这样的商业软件可以移动其中的一些文件(通常是系统文件)。你可以试试他们的试用版。

于 2008-09-09T15:35:37.913 回答
0

Contig 可能会满足您的目的http://technet.microsoft.com/en-us/sysinternals/bb897428.aspx

我相对确定我遇到了一些您可以通过编程方式访问的方法/属性来完全按照您的意愿行事。不过那是在NT4天,我的记忆力不是很好。

于 2008-09-09T15:48:43.763 回答
0

For a little more complete solution try Raxco's PerfectDisk. While it is a commercial product it does a very good job and supports boot time defrag of system files. The first defrag takes longer than say DiskKeeper but its a single pass defragger and supports defragging with very little free space left on the drive. Overall its a much smarter defrag program then any other I've seen and supports systems of any size.

http://www.raxco.com/

于 2008-09-09T16:14:25.930 回答
0

首先尝试在安全模式下移动(或删除)文件。如果不能,请尝试使用 linux 移动(或删除)文件。

但要小心,如果这些是 Windows 系统文件,那么你将无法启动你的 Windows。

文件无法移动的一些原因是:文件太大,文件处于打开/使用状态,安全权限不足,被其他计算机访问,以及许多其他原因。

于 2012-01-19T22:01:45.573 回答