Clear 0-byte files and folders and 0-byte files

Source: Internet
Author: User
Tags clear internet

Clear 0-byte files and folders and 0-byte files

Recently, I suddenly felt that my personal development machine was slow. So have I been with this old antique for more than seven years since I went to college, fortunately, I will personally clean and maintain it once or twice a year, so it can still work for me. If I remember correctly, I have been working on the system for more than two years. I checked the disk information. In Windows 2003, The system disk occupied 45 GB (full 50 GB, this also includes 4 GB of virtual memory), and various folders and files are accumulated on other hard disks, either by yourself or by hard work. If you do not delete it, it is a pile of garbage. What should I do?

Set this rule for yourself first

1. the folder depth cannot exceed 5

2. Do not retain 0-byte files and folders

3. Execute disk fragment (File compression is also a good way to reorganize the scattered files, and then decompress the files. If you don't understand it, you should be at Hu grui)

 

How can we quickly implement these steps?

 

 

1. the folder depth cannot exceed 5

 

The cmd command has a tree. Do you know the tree?

C: \ Users \ Administrator> tree "D: \ Moontest \ Moontest \ delete 0 size files and empty folders" / f
Folder PATH list
Volume serial number is A043-7C6D
D: \ MOONTEST \ MOONTEST \ delete 0 size files and empty folders
│ Program.cs
│ Delete 0 size files and empty folders.csproj
│
├─bin
│ ├─Debug
│ │ delete 0 size files and empty folders.exe
│ │ delete 0 size files and empty folders. Pdb
│ │ Delete 0 size files and empty folders. Vshost.exe
│ │ Delete 0 size files and empty folders. Vshost.exe.manifest
│ │
│ └─Release
├─Controls
│ MyButton.cs
│
├─obj
│ └─x86
│ └─Debug
│ │ 1111.csproj.FileListAbsolute.txt
│ │ 2048.csproj.FileListAbsolute.txt
│ │ DesignTimeResolveAssemblyReferences.cache
│ │ DesignTimeResolveAssemblyReferencesInput.cache
│ │ GenerateResource.read.1.tlog
│ │ GenerateResource.write.1.tlog
│ │ ResolveAssemblyReference.cache
│ │ Delete 0 size files and empty folders.csproj.FileListAbsolute.txt
│ │ delete 0 size files and empty folders.exe
│ │ Delete 0 size files and empty folders. Properties.Resources.resources
│ │
│ └─TempPE
│ Properties.Resources.Designer.cs.dll
│
└─Properties
        AssemblyInfo.cs
        Resources.Designer.cs
        Resources.resx
        Settings.Designer.cs
        Settings.settings


C: \ Users \ Administrator> 

This level is distinct. If there are too many, you can enter> d: \ result.txt after the command, that is

Tree "D: \ Moontest \ Delete 0-size files and empty folders"/f> d: \ result.txt

Export the result to a file in this way. If the depth is too large, you can handle it manually. Do not write code for automatic processing as much as possible. After all, you cannot write your thinking into a computer, delete, merge, or shift files, it's better to work manually. Of course, I am talking about something that has value and feelings for myself. After all, some things are just like ourselves.

 

 

2. Do not retain 0-byte files and folders

No matter what kind of system cleanup tool we use, the cleanup tool considers system stability and generally does not delete 0-character files and folders that are not in the "roster. This may lead to a large number of junk files (0 character files and folders) retained in the system during installation and deletion. Over time, seeing a bunch of things that I don't know is really uncomfortable. Seeing one and killing one is slow. What should I do? Write a cleanup method by yourself.

I provide a small code for deleting a 0-character file and folder. It is relatively simple. I don't want to explain the code. It is divided into three sections and requested according to your preference. My personal preference is Class2.

Using System; using System. collections. generic; using System. IO; namespace Delete 0-size files and empty folders {class Program {/* the Class1 and Class2 formats are the same, but the deletion methods are different, the format is different. Class1 first Retrieves all folders, deletes 0-byte files from the end folder, and checks a folder in the folder Class2 and Class3. First, deletes the 0-byte file, and then retrieves the folder, repeat the preceding process and delete the folder */static void Main (string [] args) {AppDomain. currentDomain. unhandledException + = (s, e) => {File. appendAllText (AppDomain. cur Invalid domain. baseDirectory + "error. log ", DateTime. now. toString () + "\ t" + e. predictionobject. toString () + Environment. newLine) ;}; Class1 c1 = new Class1 (args); Class2 c2 = new Class2 (args); Class3 c3 = new Class3 (args );}} public class Class1 {public Class1 (string [] args) {Queue <string> queue = new Queue <string> (); stack <string> stack = new Stack <string> (); if (args. length> 0) {foreach (var it Em in args) {queue. enqueue (item); stack. push (item) ;}} else {string rootPath = AppDomain. currentDomain. baseDirectory; queue. enqueue (rootPath); stack. push (rootPath);} while (queue. count> 0) {string curPath = queue. dequeue (); string [] folders = null; try {folders = Directory. getDirectories (curPath);} catch {} if (folders! = Null & folders. length> 0) {foreach (var item in folders) {queue. enqueue (item); stack. push (item) ;}}while (stack. count> 0) {string curPath = stack. pop (); string [] files = null; try {files = Directory. getFiles (curPath);} catch {} int filecount = 0; if (files! = Null & files. length> 0) {filecount = files. length; foreach (var item in files) {FileInfo finfo = new FileInfo (item); if (finfo. length <= 0) {try {finfo. delete (); filecount --; Console. writeLine ("delete file:" + finfo. fullName);} catch (Exception ex) {Console. writeLine (ex) ;}}}if (filecount = 0) {try {Directory. delete (curPath); Console. writeLine ("delete folder:" + curPath);} ca Tch (Exception ex) {Console. WriteLine (ex) ;}} Console. WriteLine ("cleared !!! "); Console. readKey () ;}} public class Class2 {public Class2 (string [] args) {Queue <string> queue = new Queue <string> (); stack <string> stack = new Stack <string> (); if (args. length> 0) {foreach (var item in args) {queue. enqueue (item); stack. push (item) ;}} else {string rootPath = AppDomain. currentDomain. baseDirectory; queue. enqueue (rootPath); stack. push (rootPath);} while (queue. count> 0) {s Tring curPath = queue. Dequeue (); string [] files = null; try {files = Directory. GetFiles (curPath);} catch {} if (files! = Null & files. length> 0) {foreach (var item in files) {FileInfo finfo = new FileInfo (item); if (finfo. length <= 0) {try {finfo. delete (); Console. writeLine ("delete file:" + finfo. fullName);} catch (Exception ex) {Console. writeLine (ex) ;}}} string [] folders = null; try {folders = Directory. getDirectories (curPath);} catch {} if (folders! = Null & folders. length> 0) {foreach (var item in folders) {queue. enqueue (item); stack. push (item) ;}}while (stack. count> 0) {string curPath = stack. pop (); try {Directory. delete (curPath); Console. writeLine ("delete folder:" + curPath);} catch (Exception ex) {Console. writeLine (ex) ;}} Console. writeLine ("cleared !!! "); Console. readKey () ;}} public class Class3 {public Class3 (string [] args) {if (args. length = 0) {args = new string [] {AppDomain. currentDomain. baseDirectory };} foreach (var item in args) Delete (item); Console. writeLine ("cleared !!! "); Console. readKey ();} public void Delete (string path) {string [] files = null; try {files = Directory. getFiles (path);} catch {} if (files! = Null & files. length> 0) {foreach (var item in files) {FileInfo finfo = new FileInfo (item); if (finfo. length <= 0) {try {finfo. delete (); Console. writeLine ("delete file:" + finfo. fullName);} catch (Exception ex) {Console. writeLine (ex) ;}}} string [] folders = null; try {folders = Directory. getDirectories (path);} catch {} if (folders! = Null & folders. length> 0) foreach (var item in folders) Delete (item); try {Directory. delete (path); Console. writeLine ("delete folder:" + path);} catch (Exception ex) {Console. writeLine (ex );}}}}Small code

 

 

You just need to copy the generated program and run it to the disk or folder you want to clear. You can also add parameters to specify the path. For example, write a 1. cmd file and write it in it.

Call .. \ write the parent path of the Generation Program \ Generation Program .exe "c: \" "D: \ flash cs6 completely self-learning tutorial" "E: \ Erlang Project ",

Then run 1. ).

 

Now the topic is pulled back. I didn't just say that many system cleanup tools will not delete the 0-character files and folders in non-"roster" for the sake of system stability. I am doing this now, isn't the system stability greatly threatened?

Tell you, if you are using a personal computer, even if you delete it, many robust system programs have file self-recovery capabilities (this is very important in development, the configuration file is accidentally deleted, or cannot be identified by the program. The program must have the file self-recovery capability. However, this method is absolutely not allowed to clean the running server unless you think your neck is thick enough and your head cannot fall down.

 

 

3. Perform disk fragmentation

This is simple. I like to use defraggler. The execution speed is very fast and should be the same as that of ccleaner. Of course, you can also use the built-in disk sorting tool, but it is time-consuming; if the file size is large and the requirement for continuity is high, you can use the compressed file format.

 

 

 

 

In the end, you can delete, move, and merge data. Finally, the C disk is sorted out with 10 Gb of space remaining, and the other disks are also processed with duplicate files (the process of duplicate files is relatively simple. I am reading all the files on the diskFile Creation Time and file sizeConnect to the file path and insert the hash table as the key-value. Next time you encounter duplicate keys, compare the file features (when the file creation time is equal to the file sizeRandom same-bit characters, Equal matchTo determine whether the same file is deleted ).


How can I delete a 0-byte folder?

Perfect uninstallation V2006 (excellent Optimization Expert 2006)
-------------------------------
The Swiss Army Knife maintained by the system provides an excellent and inexpensive experience!

Main functions:
1. Installation and monitoring: monitor every action of the software and generate an accurate uninstall record.
2. Smart uninstall: clean and uninstall various stubborn software.
3. Uninstall maintenance: Maintain the Installation Software List, and quickly uninstall the software in two ways.
4. Spam cleaning: more than 90 spam files and more than 70 common software spam are cleared.
5. Lightning cleanup: Clean up common spam instantly, and embed IE to clear Internet traces.
6. Shortcut cleanup: Clear hidden shortcuts and desktop and Start Menu spam.
7. Advanced cleanup: maintain and clear important data in the registry.
8. DLL cleanup: Clear redundant DLL link libraries to save a lot of disk space.
9. System Repair: quickly fix security system errors and fix online upgrades of plug-ins.
10. Master optimization: hundreds of optimization rules, smart wizard optimization, and more suitable for cainiao.
11. file encryption: the safe deposit box and file encryption ensure the security of private files.
12. Disk repair: scan and fix disk table and file distribution and directory errors.
13. Driver Management: Create a Driver Installation Package and reinstall the system for one-time smart recovery.
14. Golden memory: the best memory optimization tool, which can optimize services at the same time and start upon startup.
15. vulnerability scan: perform security checks on your computer to identify and fix vulnerabilities.
16. virus scanning and removal: scan and kill popular Trojans | viruses | worms | spyware | advertising programs | malicious code.
17. System Protection: Security InterScan, leading unknown virus alerts and kernel monitoring technologies.
18. Network Security: Professional Alibaba Cloud security network firewall and first-class anti-Black assistant.
19. Information Detection: A computer hardware detection tool that provides a comprehensive understanding of system information.
20. File disguise: folder magic disguise, hiding, locking, and protecting personal privacy.
 
Can I delete some 0-byte folders and files in the windows folder on drive C?

In Windows, when the disk C space is insufficient, we can increase the disk C space by specific means.

1. Open "my computer"-"Tools"-"Folder Options"-"View"-tick-"OK" before "show all files and folders"

2. Delete the content in the following folders:

X: \ Documents and Settings \ User Name \ Cookies \ All files (keep index files)

X: \ Documents and Settings \ User Name \ Local Settings \ Temp \ All files (user temporary files)

X: \ Documents and Settings \ User Name \ LocalSettings \ TemporaryInternet Files \ All Files (page Files)

X: \ Documents and Settings \ User Name \ Local Settings \ History \ All files (History)

X: \ Documents and Settings \ USERNAME \ Recent \ All files (shortcuts to recently viewed files)

All files under x: \ WINDOWS \ Temp \ (temporary files)

X: \ WINDOWS \ ServicePackFiles (backup file after sp1 or sp2 upgrade)

X: \ WINDOWS \ Driver Cache \ i386 compressed files (Driver backup files)

X: \ WINDOWS \ SoftwareDistribution \ download all files

3. If you have upgraded the elasticsearch instance, delete the following files:

X: \ windows \ Hidden Files starting with $ u...

4. fragment the disk. Please exit all running programs during the sorting process.

5. after fragment, open "start"-"program"-"attachment"-"system tool"-"System Restore"-"Create a Restore Point" (it is best to pay back the site on the current date ). origin name)

6. open "my computer", right-click the system disk, and choose "properties"> "Disk Cleanup"> "other options". Then, click "clean" in the System Restore column and select "yes" -OK

7. After various software and hardware are installed properly, it is very rare for XP to update files. Delete the system backup file: At the beginning, Run sequence sfc.exe/purgecache near 3xxM. (The purpose of this command is to immediately clear the "Windows File Protection" File Cache and release the occupied space)

8. Delete the dll file under \ windows \ system32 \ dllcache (minus 200 -- 300 mb). This is a backup dll file. You can do this if you have copied the installation file.

9. XP will automatically back up the hardware driver. However, after the hardware driver is correctly installed, it is generally unlikely to change the hardware. Therefore, you can also consider deleting this backup, the file is located in the \ windows \ driver cache \ i386 directory and named driver. cab, you can simply delete it. Normally, this file is 74 MB.

10. delete unused input methods: For many netizens, not all input methods provided by Windows XPt are suitable for their own use, such as IMJP8_1 Japanese input method and IMKR6_1 Korean Input Method ...... remaining full text>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.