This content has been marked as final. Show 7 replies
Johnny_hunter wrote:This is no longer programming related right? If so, use Microsoft's process explorer.
my mistake - actually I meant to say the file is opened by another process, not locked. In that case, how can I find out which process opened it? It might help me investigate.
The app is for Windows.
If not: well you are not going to something as operating system specific as that using Java. In fact probably you'll have a hard time doing this using .NET, I did a quick search how to do this with the win32 API and I ended up empty handed :/
thanks gimbal. I tried process explorer before (I did google before I turned to help in here :-)...), it didn't help much then - maybe I should take a 2 ^nd^ look. Anyway.
I think this still has some relevance to programming, particularly to Swing programming. Please indulge me and let me elaborate:
- I create a JTable in which a list of files under a certain directory is shown;
- I selected one of the files and right click to bring up a popup menu;
- I chose the menu item "Move to folder" to move the select file, the code looks like
Thats where the action fails. My best guess is that the Swing component is holding the file's handle therefore it's qualified as opened by "another process".
boolean b = new File("C:\\temp\\elephnt.ttf").renameTo(new File("C:\\Users\\John\\Documents\\elephnt.ttf")); System.out.println(b);
I just don't know how to tackle the issue.
I think this still has some relevance to programming, particularly to Swing programmingHow can renaming a file have anything to do with Swing programming?
I chose the menu item "Move to folder" to move the select file, the code looks likeHow can renaming a file from one constant name to another constant name have anything to do with a 'selected file'?
boolean b = new File("C:\\temp\\elephnt.ttf").renameTo(new File("C:\\Users\\John\\Documents\\elephnt.ttf"));
The filename must be a variable!