Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Class1:



C#
public void getfol(string path)
        {

            SqlConnection conn = new SqlConnection("Data source=.;initial catalog=data_pc;integrated security=true");
           
            int i;
            try
            {
                string[] a = Directory.GetDirectories(path);
                for (i = 0; ; i++)
                {
                    SqlCommand cmd = new SqlCommand("insert into con values(@p)", conn);
                    cmd.Parameters.AddWithValue("@p", a[i]);
                    Console.WriteLine(a[i]);

                    bool isa = ((File.GetAttributes(a[i]) & FileAttributes.System) == FileAttributes.System);
                    if (isa == true)
                    {
                        SqlCommand md = new SqlCommand("insert into con values(@p)", conn);
                        md.Parameters.AddWithValue("@p", "next");
                        Console.WriteLine("bliisdsdsdszdsafsfdsF");

                        i++;

                    }

                    if (Directory.GetDirectories(a[i]).Length > 0)
                    {

                        getfol(a[i]);


                    }


                    if (Directory.GetFiles(a[i]).Length > 0)
                    {
                        getfil(a[i]);


                    }

                }

            }

            catch (Exception ec)
            {
                Console.WriteLine(ec.Message);
            }
        }
        public void getfil(String path)
        {
            SqlConnection conn = new SqlConnection("Data source=.;initial catalog=data_pc;integrated security=true");

            string[] p = Directory.GetFiles(path);
            for (int j = 0; j < p.Length; j++)
            {
                SqlCommand cmd = new SqlCommand("insert into con values(@p)", conn);
                cmd.Parameters.AddWithValue("@p", p[j]);
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                Console.WriteLine(p[j]);
            }
        }

    }





Program.cs
C#
Class1 obj = new Class1();
            DriveInfo[] ab = DriveInfo.GetDrives();
            String str;
            for (int i = 0; i < ab.Length; i++)
            {
                str = ab[i].ToString();
                obj.getfol(str);
            }
            Console.ReadLine();




I wrote this program to retrieve all the contents of a hard disk in c# application. Now i want that it must be retrieve all contents on background and must show me a progress bar on a form. I want my application should run as background service i.e it must not be closed after pressing X on the form and must be minimized in the taskbar's left corner as in windows xp.
Additionly,It would be appreciable if any could tell me that how can i make this generated cache fulltext indexed in sql server 2005. I don't have the full text services installed so please provide me a link for downloading separate files for sql server 2005 to install freetext in it.
Regards,
Yours Sincerly,
Akky.
Posted
Comments
Akkywadhwa 4-Sep-12 12:23pm    
This line " Console.WriteLine("bliisdsdsdszdsafsfdsF");" is a separator please don't consider this.
Akky
[no name] 4-Sep-12 12:27pm    
Okay.... did you perhaps have some sort of specific question related to a specific programming problem or did you just want people to do your research for you? "I want" is not a question. 1. Okay so? Use a background thread and a progress bar. 2. So minimze your program to the tackbar. 3. Get your installation files and install the additional files for the text search capability.

1 solution

SQL Server is not meant to be used in this way.

Try using lucene.net[^] or my article hOOt - full text search engine[^].
 
Share this answer
 
Comments
Manas Bhardwaj 4-Sep-12 16:17pm    
5ed!
Mehdi Gholam 5-Sep-12 1:25am    
Thanks Manas!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900