i'm trying to make a program that downloads some files, and now i want to open the folder (on the windows explorer) where those files are (it's always the same folder) and select the last file that was downloaded, i found this code to do it on java:
It works, but every time i press the button to open the folder it opens a new explorer window with the selected file so i end up with many explorer windows opened. Is there a way to do this on the folder that is already open?
I've been looking on the web for this but i only found the same code that i'm already using. All of those other posts about this issue are from many years ago so i don't know if it used to work that way on previous versions.
Thank you so much if any of you can help me.
Code:
private void openFile(File f) { try { Runtime.getRuntime().exec("explorer.exe /select," + f.getAbsolutePath()); } catch (Exception ex) { System.out.println("Error - " + ex); } }
I've been looking on the web for this but i only found the same code that i'm already using. All of those other posts about this issue are from many years ago so i don't know if it used to work that way on previous versions.
Thank you so much if any of you can help me.
Comment