So, I encountered a problem where a file couldn't be copied from one place to another using drag and drop feature of java. I think the problem is the pathname because some files that I dragged got copied well except from files with long path names. The program is being run in Windows 7 and I'm aware of Windows 7 path name limit(which is 255-260 according to the sources that I've read). When I used windows explorer to drag files the file with long path name got copied successfully. My solution here is to inform the user about the long file path name and let them shorten the path name. I just wanna know if there's a solution to bypass that long path name problem like windows explorer does?
This is the length of the file that I was talking about
The program is also being used to drag files from the program to a file hosting website and website gives this error
So Java drag-and-drop is providing the correct file name to the browser, but the browser has a problem with that file name? Then I don't see why the problem is related to Java drag-and-drop in any way.
If you try copying the long file name from Notepad++ and pasting it into the browser, what happens? Prediction: the browser will have a problem.
This is the result if I drag and drop file with long path name using windows explorer
In this attempt. the file is successfully loaded to the file uploader all I need to do is to click the upload button
This is the result If I drag and drop file with long path name using java
The problem only happens in files with long path names. Windows explorer drag and drop and java drag and drop work well with file with short path name. When it comes to long path name, Windows explorer drag and drop still works but java drag and drop doesn't
I also tried to compare the windows explorer and java drag and drop on desktop and java drag and drop still has the problem. When I use windows explorer to drag a file with long path name to desktop, It successfully copied the file to desktop. Java, on the other hand, didn't successfully copy the file.
I also noticed that file path of the file with long file name is somewhat weird when I look at its properties in windows explorer
Portion of the path of file with long path name
Portion of the path of file with short path name
D:\Logical(Not Installed) Files\Uploads\
Though, The path of the file with long path name that I'm getting in java is normal.
Windows carries a legacy from DOS which got its original filesystem and I/O services from floppy disks which had 11-character fixed character slots for filenames: 8 for the base name and 3 for the extension. Known as "8.3" notation.
When Windows took over, it added more intelligent filesystems - notably NTFS - which no longer carried that restriction. But to support legacy DOS programs, mechanisms were built in to curtate long names into 8.3-friendly forms. Such as "LOGICA~1". Or one that everyone loves, PROGRA~1 for "Program Files".
Note that this curtation system is not wholly predictable. In cases of collision, other values may be used. I have seen the occasional PROGRA~2 directory, for example.
Java, of course, being write-once/run-anywhere has no use for such foolishness and never employs, requires or enforces 8.3 itself.
Loudly announcing something is true and finding out you're wrong makes you feel foolish.
Finding out you're wrong and refusing to admit it makes you LOOK foolish.