Im très nouveau pour le code et je voudrais savoir comment puis-je lier un bouton dans Visual Studio pour ouvrir un fichier sur votre bureau? System.Diagnostics.Process.Start("C:/Users/Desktop");
travail doesent Aide s'il vous plaît: DComment ouvrir un fichier sur le bureau C#
Répondre
Voici votre exemple souhaité:
// Get the desktop folder path of the current user
string folderpath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
// define the filename of the file you want to open
string filename = "desktop.ini";
// Get the full path of the folder and filename combined. Path.Combine will add slash automatically
string filepath = System.IO.Path.Combine(folderpath, filename);
// Open the file with the defined filepath
System.Diagnostics.Process.Start(filepath);
https://gyazo.com/57d6636d4a1086771fed36887f282286 –
J'ai changé mon exemple. J'ai oublié de renommer la variable de chemin et d'utiliser system.io pour Path.Combine. –
Puis-je faire ça? [lien] http://pastebin.com/5PUgJ6aY? –
Il vous manque le nom d'utilisateur ' "C:/Users//Desktop/"'. Vous pouvez obtenir le chemin vers le bureau de l'utilisateur actuel avec ceci: 'chemin de chaîne = Environment.GetFolderPath (Environment.SpecialFolder.Desktop);' –
pouvez-vous donner un exaple s'il vous plaît? –
Voulez-vous ouvrir un dossier? Ou voulez-vous afficher une boîte de dialogue permettant à l'utilisateur d'ouvrir un fichier sur un dossier donné? Ou voulez-vous lire le contenu du fichier? – kurakura88