Cannot delete file, "Source filename length is greater than system supported length"

Source: Internet
Author: User

Sometimes when you delete a directory in Windows, the "source file name length is greater than the length of the system support", and can not be deleted, as a program ape, how can this be impressed by this, on the code:

Import java.io.file;/** * @author Wu Qinglong * October 13, 2015 PM 1:22:33 */public class Deletefiles {public static void Deletefiles ( File file) {if (File.isdirectory ()) {//If it is a directory, first find all files or directories under this directory//and then delete file[] files = file.listfiles (); if (Files.len Gth = = 0) {//If it is an empty directory, delete file.delete directly ();} else {//If it is not an empty directory, then recursive for (File f:files) {deletefiles (f);//After the removal of recursion, delete this directory f.d Elete ();}}} else {//If it is a file, delete file.delete directly ();}} public static void Main (string[] args) {File file = new file ("D:\\Program files\\myeclipse2015");d eletefiles (file);}


This article is from the "focus on Java,linux Technology" blog, please be sure to keep this source http://wuqinglong.blog.51cto.com/9087037/1711598

Cannot delete file, "Source filename is longer than system supported"

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.