is it possible to Defragment through the C code, and how?
Learn something new every day More Info... by email
In the normal course of using a computer files and folders become fragmented on the hard drive(s). What this means is that files are not located intact in contiguous space but spread out in bits here and there. Retrieval and even saving files takes longer and in extreme cases can lead to errors. To improve performance, one should defragment drives as part of routine computer maintenance.
Software designed to defragment reads data and writes fragments to available space, recombining the fragments into complete files. Some types of defraggers will relocate program files together, and move data to the front of the drive, leaving all available space to occupy a single contiguous location behind stored data. Other programs do not condense available space, or in some cases it's an option that is user configurable.
Many factors play into how long it takes to defragment a drive. The design of the software itself can add to the time factor or speed along the process. A large drive with a lot of data will obviously take longer to defrag than a small drive with little data, and a drive that is nearly full, be it small or large, also adds to the time factor because there is so little available space to work within in the defragging process. Regardless, regular defragmenting cuts down on the time it takes to complete the job, and in the best case scenario it will only take a few minutes. If defragging has never been done on a large storage space, leaving the defragger to run overnight might be a good idea.
Most operating systems (OSs) such as Windows® include a built-in defragger. You can reach it through different paths, depending on the OS. In XP® try the Start button, Programs, Accessories, highlight System Tools, and look for Disk Defragmenter. If you can't find it, go to the system's main Help menu and search for "disk defragmentation."
Some people prefer using a third party program to defragment. One popular commercial program is Diskeeper®, which includes the ability to defragment at shutdown or startup. This allows the program to defrag the pagefile, which isn’t available when booted into Windows. You can also choose to have defragmentation running continuously in the background, preventing disks from becoming fragmented in the first place; though some believe this causes undo wear-and-tear on the drive. If you prefer lean software, an optional, free, open-source program is UltraDefrag©.
In addition to these two programs that bookend opposite ends of the spectrum, there are many proprietary shareware programs that fall between. Read reviews from reputable websites to get an idea of which program you might like.
While defragging should not cause problems, it’s always wise to backup the system before performing maintenance, then again when finished. Since the process can slow the system depending on the program used and other factors, it might be better to manually start the process when you won’t be working on the computer. Otherwise the scheduler should be set to defragment at least once monthly, and preferably every two weeks, or as needed.
One of our editors will review your suggestion and make changes if warranted. Note that depending on the number of suggestions we receive, this can take anywhere from a few hours to a few days. Thank you for helping to improve wiseGEEK!