Bonjour,

Je fais un programme qui génère des fichiers .xml et les placent dans un dossier relatif à la racine du projet. J'aimerais pouvoir les ouvrir à partir de mon programme. Pour cela, j'ai tenté d'y accéder de cette facon :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
 try
            {
                String filePath = new File("Files/Dossier/mon fichier.xml").getCanonicalPath();
                String command = "cmd /" + filePath.charAt(0) + " " + filePath;
                Runtime.getRuntime().exec(command);
            }
            catch (IOException ex)
            {
                ex.printStackTrace();
            }
mais rien ne se passe...
Or, le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
    try
            {
                String filePath = new File("C\\Users\\monfichier.xml").getCanonicalPath();
                String command = "cmd /" + filePath.charAt(0) + " " + filePath;
                Runtime.getRuntime().exec(command);
            }
            catch (IOException ex)
            {
                ex.printStackTrace();
            }
lui marche bien mais pas :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
  try
            {
                String filePath = new File("C\\Users\\Nom Utilisateur\\monfichier.xml").getCanonicalPath();
                String command = "cmd /" + filePath.charAt(0) + " " + filePath;
                Runtime.getRuntime().exec(command);
            }
            catch (IOException ex)
            {
                ex.printStackTrace();
            }
On dirait que je n'ai pas la permission d'accéder au dossier "Nom Utilisateur".
Comment pourrais je accéder à ce fichier?

Merci :-)