C#C
C#3y ago
Maybe Ange

❔ [FIX} Csharp & Python / WPF APP

I have a problem with this code, in fact I have a button on my WPF software and when I click on it it executes a separate python script in another file.
The problem is that the software returns me my error I made in "Try" and tells me that it can't find the file and it can't run it, yet I don't understand the path is ok , can someone help me?

private void Button_Click(object sender, RoutedEventArgs e)
        {
            string pythonPath = @"C:\Program Files\Python\Python39\python.exe";
            string scriptPath = @"D:\Documents\Script security network\Software Box\Software\Reload Box\scripts\reload-no-time.py";

            try
            {
                if (!File.Exists(scriptPath))
                {
                    throw new FileNotFoundException("Le fichier de script n'existe pas", scriptPath);
                }
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show($"Erreur : {ex.Message}");
                return;
            }
Was this page helpful?