简体   繁体   中英

Windows couldn't remove file with large path

Google Web Toolkit (GWT) generates huge number of temporary files in the temp (C:\\Users\\User01\\AppData\\Local\\Temp) directory.

Example of a file path:

C:\Users\User01\AppData\Local\Temp\gwt-codeserver-1101830889369654349.tmp\com.company01.web.builder.BuildingsWeb\compile-2\gen\com\company01\web\theme\custom_pluto123\client\base\progressbar\Css3ProgressBarAppearance_Css3ProgressBarTemplate_render_SafeHtml__SafeHtml_text__Css3ProgressBarStyles_style__SafeStyles_wrapStyles__SafeStyles_progressBarStyles__SafeStyles_progressTextStyles__SafeStyles_widthStyles___SafeHtmlTemplatesImpl.java

The above file path contains 437 characters.

When I tried to remove this type of files from Windows Explorer, it got crashed. Also I've tried to remove or rename it from command prompt it says The filename or extension is too long.

Finally I deleted by running custom java program.

Now, my question is why Windows couldn't able to remove it? If its not supported by OS, how java removes it?

Note:

  • I tried all of the above commands/actions with proper UAC (Run as administrator) in Windows 7 Ultimate and the File System was NTFS

Windows had an limitation of 260 characters (=MAX_PATH) but now also allows to create paths with up to 32,767 characters through the Unicode version of its API.

Windows Explorer sadly cannot handle long paths.

Java seems to use the Unicode API and therefore can create and remove long paths.

Resources:

  1. https://support.microsoft.com/en-us/kb/320081
  2. https://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM