Les Snippets

Connexion

Créer un dossier sur le bureau

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 21/12/2007 13:20:36 et initié par PCPT [Liste]
Date de mise à jour : 23/01/2008 13:36:20
Vue : 9498
Catégorie(s) : API, Fichier / Disque
Langages dispo pour ce code :
- VB6, VBA
- C# 1.x, C# 2.x
- Python
- VB 2005



Langage : VB6 , VBA
Date ajout : 21/12/2007
Posté par PCPT [Liste]
Private Const DESKTOP As Long &H0
Private Type SHITEMID
    SHItem As Long
    itemID() As Byte
End Type
Private Type ITEMIDLIST
    shellID As SHITEMID
End Type
Private Declare Function MakeSureDirectoryPathExists Lib  "imagehlp.dll" (ByVal lpPath As StringAs Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal shidl As LongByVal shPath As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib  "shell32.dll" (ByVal hWnd As LongByVal folderid As Long, shidl As ITEMIDLIST) As  Long

Function CreateForderOnDesktop(ByVal sFolder As String) As String
'   retourne vide si  échec, sinon le nom du chemin complet
    CreateForderOnDesktop = vbNullString
    Dim tIDL As ITEMIDLIST, sBuffer As String, sRet As String
    
    If LenB(sFolder) Then
'       chemin  DESKTOP
        sBuffer = Space$(256)
        If SHGetSpecialFolderLocation(App.hInstance, DESKTOP, tIDL) =  0 Then
            If SHGetPathFromIDList(ByVal tIDL.shellID.SHItem, ByVal sBuffer) Then
                sRet = Left$(sBuffer, InStr(sBuffer, Chr$(0)) -  1)
                If Not (RightB$(sRet, 2) = "\"Then sRet = sRet & "\"
                sRet = sRet & sFolder & "\"
'               crée le dossier.  pas d'erreur s'il existe puisqu'il sera toujours existant  ensuite
                If Not (MakeSureDirectoryPathExists(sRet) = 0) Then  CreateForderOnDesktop =  sRet
            End If
        End If
    End If
End Function

Remarque :
MsgBox CreateForderOnDesktop("nouveau dossier")
MsgBox CreateForderOnDesktop("dossier*invalide")
Langage : C# 1.x , C# 2.x
Date ajout : 13/01/2008
Posté par Bidou [Liste]
public static void CreateDirectoryOnDesktop(string directoryName) 
{
   Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), directoryName)); 
}

Langage : Python
Date ajout : 15/01/2008
Posté par 0x586e [Liste]
import os
mkdr = lambda n: os.mkdir(os.environ['USERPROFILE']+('\\Bureau\\' if os.environ['OS'] == 'Windows_NT' else '\\Desktop\\')+n)
Remarque :
Utilisation :
mkdr(Nom-Du-Futur-Dossier)

Remarque :
Devrait marcher sous windows et linux (j'ai pas testé sous nux)
Langage : VB 2005
Date ajout : 23/01/2008
Posté par jrivet [Liste]
DateMAJ : 23/01/2008
Public Sub CreateDirectoryOnDesktop(ByVal directoryName As String)    Dim DesktopPathD As String = Environment.GetFolderPath (Environment.SpecialFolder.DesktopDirectory)    My.Computer.FileSystem.CreateDirectory (DesktopPathD & "\" & directoryName) End Sub
By Renfield

Snippets en rapport avec : Dossier, Bureau, Créer, Desktop



Codes sources en rapport avec : Dossier, Bureau, Créer, Desktop

{Visual Basic, VB6, VB.NET, VB 2005} DESKTOP WALLPAPER V 5.0
Ce programme vous permet de choisir 3 images Bmp favoris (que vous pouvez modifier à chaque fois), p...

{Visual Basic, VB6, VB.NET, VB 2005} WINBUR VERSION 1.0.2
Profitez pleinement de votre fond d'écran et beaucoup d'autres choses à découvrir. Une approche dif...

{PHP} RENVOI UN DOSSIER DE NOM UNIQUE ET ALÉATOIRE
Petite fonction permettant de renvoyer un dossier disponible de nom aléatoire dans le chemin précisé...

{C# / C#.NET} DESKTOP WINDOWS
Ceci est un bureau Windows, sur lequel on peut mettre des icônes images, on peut également protéger ...

{Visual Basic, VB6, VB.NET, VB 2005} FROSTDESKTOP 2007 - DES ÉCRANS VIRTUELS À LA LINUX
Bonjour à tous, je poste ici ma première source sur VBFrance.com. Il sagit d'un logiciel qui permet...

{Visual Basic, VB6, VB.NET, VB 2005} DESSINER EN ARRIERE PLAN DU BUREAU
Bonjour sui te a ma derniere source shadowmoy m'a fait remarquer qu'il etait possible de dessiner "e...

{IRC} WALLPAPERS POUR VOTRE BUREAU
N'ayant plus d'idées de scripts à développer voici la seule chose que j'ai trouvé à faire : Cet a...

{Delphi} CRÉATION DE FICHIERS TEMPORAIRES DANS LE DOSSIER TEMPORAIRE COURANT.(API)
Ayant eu besoin de travailler avec des fichiers temporaires, je suis tombé par hasard sur 2 fonction...

{Visual Basic, VB6, VB.NET, VB 2005} PAPIER PEINT DU BUREAU ANIMÉ
Toujours + de VB6, d'APi Windows, de VB2008 et de personnalisations pour vos programmes, sites inter...

{C / C++ / C++.NET} BUREAUX VIRTUELS (WIN32)
Ce programme permet d'avoir 4 bureaux différents pour afficher des fenêtres. Les icones du bureau so...