Official page of the section Qt in Algeria at Facebook .
This page wants to be an Algerian group for all users of Qt! .
This page wants to be an Algerian group for all users of Qt! .
You're welcome!!
Qt and .NET are a Tech 4 Art!!
Commencez déjà par importer le namespace System.IO :
using System.IO;
1: private Int64 DirectoryLength(DirectoryInfo folder)
2: {
3: Int64 bytes = 0;
4: foreach (FileInfo fi in folder.GetFiles())
5: bytes += fi.Length;
6:
7: foreach (DirectoryInfo i in folder.GetDirectories())
8: bytes += DirectoryLength(i);
9:
10: return bytes;
11: }
1: private void Form1_Load(object sender, EventArgs e)
2: {
3: // Le @ permet d'échapper tous les caractères spéciaux
4: String folder = @"C:\DossierATester\";5:6: // Si le dossier n'existe pas on arrête de traitement7: if (!Directory.Exists(folder))8: return;9:10: // Le dossier existe, on peut calculer sa taille11: Int64 size = DirectoryLength(new DirectoryInfo(folder));12:13: // Ensuite on l'affiche14: Console.WriteLine("Taille du dossier '{0}' : {1} Mo", folder, size.ToMo());
15: }
Mais qu’est ce que "size.ToMo()” ?
Une méthode d’extention :
1: public static class Functions
2: {
3: public static String ToMo(this Int64 input)
4: {
5: // N02 permet d'afficher au format : 1 234.56
6: return (input / (1024 * 1024)).ToString("N02");
7: }
8: }
Vous pouvez donc télécharger les fichiers PDF en anglais sur Microsoft Download : environnement C# et environnement VB.NET.