Hi guys,
i have about 500 folder and each folder has 2 text files.I need to insert all those files in database.Right now my program has to read each and every folder, is there any other alternative to this.

Your problem looks like the classic trick question: "What is the time complexity of printing a binary search tree?". It is a trick question because "everyone knows" that binary search trees are have logarithmic complexity, but to print all of the nodes in the tree, the algorithm still has to visit all of the nodes. So the complexity is linear.

Likewise, if you need to insert all files into the data base and the files are spread across 500 folders, you still need to check every folder. The best you can get is a linear traversal of the folders.

wow!!! thanks so i am stuck for this stupid thing for days.

> so i am stuck for this stupid thing for days.
Enumerating folders is easy in C#. Just call Directory.GetDirectories().

i tried that , it gives me error , access to the directory path denied

Then you probably don't have the necessary permissions to read from the folders. Try running the program as a user with sufficient rights.

how can we get rights.These folders are in a cd.I have no idea how to do it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.