1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
private void Execute(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();
string message = "Classe ajoutée !";
string title = "AddClass";
//////////////////////////////////////////////////////////
// Récupération de la saisie
string className = "testClass";
string extension = ".cs";
className = className + extension;
// Récupération du path utilisateur
string pathUser = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));
// Création des fichiers
string pathString = System.IO.Path.Combine(pathUser, className);
if (!System.IO.File.Exists(pathString))
{
using (System.IO.FileStream fs = System.IO.File.Create(pathString))
{
for (byte i = 0; i < 100; i++)
{
fs.WriteByte(i);
}
}
}
else
{
message = "Erreur, classe déjà existante !";
}
// Ecriture des fichiers
//////////////////////////////////////////////////////////
// Afficher une boîte de message pour prouver que nous étions ici
VsShellUtilities.ShowMessageBox(
this.package,
message,
title,
OLEMSGICON.OLEMSGICON_INFO,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
} |
Partager