Privacy policy. Deletes one or more files. This command performs the same actions as the erase command. The del command can also run from the Windows Recovery Console, using different parameters.
To confirm the deletion, press Y. To cancel the deletion and to display the next file name if you specified a group of files , press N. However, to avoid deleting files unintentionally, you should use wildcards cautiously. Availability Del syntax Del examples. Windows , Windows XP, and later syntax. Windows 95, 98, and ME syntax. Tip Use the rmdir or deltree command to delete directories. Some people always add the inquire option when deleting directories, like this:.
Unix and Linux systems have always supported wildcard characters, so in this case you can delete files and directories even faster. For instance, to delete all HTML files in the current directory, use this command:. Note that unlike DOS, you don't actually need the ". Unix and Linux wildcard characters and commands don't care at all about ". You can also use wildcard characters in the middle of a filename or at the end of the filename. Here's an example where I'm deleting all files in the current directory that begin with the string "index":.
This command deletes files named index. Which is a shame because using DirectoryInfo. GetFiles which was the original answer is the only way to do it for earlier versions of. This answer, Directory. EnumerateFiles , is still faster than then accepted one as it returns an IEnumerable of strings, rather than FileInfo classes where all the other properties need to be populated too.
If want to do something else with the file information before or after deleting it, use DirectorInfo, but if you are just deleting use Directory. In a large directory it will be a lot faster. I appreciate this thread is a little old now, but if you want to use linq then Directory. ForEach File. Delete ;. Sign up or log in Sign up using Google.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.
0コメント