cs_coq
Messages postés6349Date d'inscriptionsamedi 1 juin 2002StatutMembreDernière intervention 2 août 2014101 3 déc. 2004 à 08:22
en parcourant toute l'arborescence à partir du rep de départ désiré en regardant dans chaque rep si le fichier ne s'y trouve pas
pour ça tu devrais trouver pas mal d'exemples de code
cs_yoannd
Messages postés305Date d'inscriptionlundi 7 janvier 2002StatutMembreDernière intervention10 août 20117 3 déc. 2004 à 17:04
Le code suivant te permet de scanner tous les fichiers de ton disque dur. A toi de modifier le code, et principallement la fonction "InspecteFichier", pour correcpondre à ce que tu cherches.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Threading;
namespace test{
public class MainForm : System.Windows.Forms.Form{
private System.Windows.Forms.Label label1;
public MainForm(){
InitializeComponent();
this.Show();
// Commencer le recherche
StartSearch("c:\");
}
public void StartSearch(string FolderName){
DirectoryInfo f = new DirectoryInfo(FolderName);
ListeRepertoire(f);
}
private void ListeRepertoire(DirectoryInfo folder){
// Inspection des fichiers
FileInfo[] files = folder.GetFiles();
foreach(FileInfo file in files){
InspecteFichier(file);
Thread.Sleep(10);
}
// Inspection des sous répertoires
DirectoryInfo[] dirs = folder.GetDirectories();
foreach(DirectoryInfo subdir in dirs){
ListeRepertoire(subdir);
Thread.Sleep(10);
}
}
[STAThread]
public static void Main(string[] args){
Application.Run(new MainForm());
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 64);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(256, 24);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.label1);
this.Name = "MainForm";
this.Text = "MainForm";
this.ResumeLayout(false);
}
#endregion
}
}
creanova2000
Messages postés39Date d'inscriptionjeudi 31 juillet 2003StatutMembreDernière intervention21 septembre 20065 17 déc. 2004 à 08:00
Bonjour,
J'ai essaye d'appliquer le code qui suivrea. Le prbleme que quand je clique en dehors de la forme de l'application lors de son execution , l'application plante.
S'il vous plait comment eviter que l'application plante ?
le code est :
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Threading;
namespace test{
public class MainForm : System.Windows.Forms.Form{
private System.Windows.Forms.Label label1;
public MainForm(){
InitializeComponent();
this.Show();
// Commencer le recherche
StartSearch("c:\");
}
public void StartSearch(string FolderName){
DirectoryInfo f = new DirectoryInfo(FolderName);
ListeRepertoire(f);
}
private void ListeRepertoire(DirectoryInfo folder){
// Inspection des fichiers
FileInfo[] files = folder.GetFiles();
foreach(FileInfo file in files){
InspecteFichier(file);
Thread.Sleep(10);
}
// Inspection des sous répertoires
DirectoryInfo[] dirs = folder.GetDirectories();
foreach(DirectoryInfo subdir in dirs){
ListeRepertoire(subdir);
Thread.Sleep(10);
}
}
[STAThread]
public static void Main(string[] args){
Application.Run(new MainForm());
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 64);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(256, 24);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.label1);
this.Name = "MainForm";
this.Text = "MainForm";
this.ResumeLayout(false);
}
#endregion
}
}
creanova2000
Messages postés39Date d'inscriptionjeudi 31 juillet 2003StatutMembreDernière intervention21 septembre 20065 17 déc. 2004 à 08:44
En effet ce qui se passe la fenetre devient blanche et si je clique une autre fois dedans j'ai la barre de propriete "cette application ne reponds pas"
Comment peut on resoudre ce probleme je veux dire celuis de l'affichage.