Click here to Skip to main content
15,914,074 members
Home / Discussions / C#
   

C#

 
QuestionSample Code for SetWinEventHook in C# Pin
Pattabhirama15-Jan-07 21:01
Pattabhirama15-Jan-07 21:01 
AnswerRe: Sample Code for SetWinEventHook in C# Pin
Christian Graus15-Jan-07 21:45
protectorChristian Graus15-Jan-07 21:45 
GeneralRe: Sample Code for SetWinEventHook in C# Pin
Pattabhirama15-Jan-07 22:06
Pattabhirama15-Jan-07 22:06 
GeneralRe: Sample Code for SetWinEventHook in C# Pin
Christian Graus15-Jan-07 22:08
protectorChristian Graus15-Jan-07 22:08 
GeneralRe: Sample Code for SetWinEventHook in C# Pin
Art Taradeiko25-Sep-13 5:17
Art Taradeiko25-Sep-13 5:17 
QuestionHow to detect if a service is running or not Pin
bouli15-Jan-07 20:57
bouli15-Jan-07 20:57 
AnswerRe: How to detect if a service is running or not Pin
Kodanda Pani15-Jan-07 23:19
Kodanda Pani15-Jan-07 23:19 
AnswerRe: How to detect if a service is running or not Pin
justintimberlake16-Jan-07 1:00
justintimberlake16-Jan-07 1:00 
GeneralRe: How to detect if a service is running or not Pin
bouli16-Jan-07 2:11
bouli16-Jan-07 2:11 
QuestionTemplate Programming Pin
satsumatable15-Jan-07 20:20
satsumatable15-Jan-07 20:20 
AnswerRe: Template Programming Pin
Christian Graus15-Jan-07 21:43
protectorChristian Graus15-Jan-07 21:43 
QuestionRecursive directory search Pin
electriac15-Jan-07 20:06
electriac15-Jan-07 20:06 
AnswerRe: Recursive directory search Pin
Luc Pattyn15-Jan-07 21:04
sitebuilderLuc Pattyn15-Jan-07 21:04 
GeneralRe: Recursive directory search Pin
electriac15-Jan-07 21:19
electriac15-Jan-07 21:19 
GeneralRe: Recursive directory search Pin
electriac15-Jan-07 21:52
electriac15-Jan-07 21:52 
GeneralRe: Recursive directory search Pin
Luc Pattyn15-Jan-07 22:22
sitebuilderLuc Pattyn15-Jan-07 22:22 
AnswerRe: Recursive directory search Pin
Christian Graus15-Jan-07 21:48
protectorChristian Graus15-Jan-07 21:48 
GeneralRe: Recursive directory search Pin
electriac15-Jan-07 21:54
electriac15-Jan-07 21:54 
GeneralRe: Recursive directory search Pin
Christian Graus15-Jan-07 22:00
protectorChristian Graus15-Jan-07 22:00 
GeneralRe: Recursive directory search Pin
electriac15-Jan-07 22:09
electriac15-Jan-07 22:09 
AnswerRe: Recursive directory search Pin
Luc Pattyn15-Jan-07 22:27
sitebuilderLuc Pattyn15-Jan-07 22:27 
GeneralRe: Recursive directory search Pin
electriac16-Jan-07 0:21
electriac16-Jan-07 0:21 
I have revised my program to examine all the files on the C: drive. I have placed the files in a sorted list box.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
//using System.Net;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        static int countFiles = 0;
        public Form1()
        {
            InitializeComponent();
        }
        ArrayList list = new ArrayList();
     //--------------------------------------------------------// 
     //------There is something wrong with this function ------//
     //--------------------------------------------------------//
        void DirSearch(string sDir)
        {
            try
            {
                foreach (string d in Directory.GetDirectories(sDir))
                {
                    foreach (string f in Directory.GetFiles(d, "*.*"))
                    {
                        list.Add(f);
                        countFiles++;
                    }
                    DirSearch(d);
                }
            }
            catch (System.Exception excpt)
            {
                Console.WriteLine(excpt.Message);
            }
        }
      //------------------------------------------------------//  
        private void button1_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            listBox1.Items.Clear();
            listBox1.Sorted = true;
            list.Clear();
            countFiles = 0;
            DirSearch("c:\\");
            foreach (string s in list) listBox1.Items.Add(s);
            listBox1.Items.Add(" --> Number Of Files = " + countFiles);
            this.Cursor = Cursors.Default;
        }
    }
}


When I run this code all directories begining with the letter 't' or more are NOT present this includes the "Windows" directory. I have now tested this on four different machines all of which report the same erroneus result. A directory called "system" is found and one called "text" is not.
GeneralRe: Recursive directory search Pin
Luc Pattyn16-Jan-07 1:14
sitebuilderLuc Pattyn16-Jan-07 1:14 
GeneralRe: Recursive directory search Pin
electriac16-Jan-07 1:31
electriac16-Jan-07 1:31 
GeneralRe: Recursive directory search Pin
Luc Pattyn16-Jan-07 1:31
sitebuilderLuc Pattyn16-Jan-07 1:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.