Category Archives: directories

Find files in the startup directory in C#

In some programs you may want to find files that were installed with the program. One way to do that is to put the files in the program’s installation directory. Open the Project menu, select Add Existing Item, find the … Continue reading

Posted in directories, files | Tagged , , , , , , , , , , , , | Leave a comment

List the locations of special folders in C#

The System.Environment class’s SpecialFolders enumeration lists special folders such as System, Cookies, Desktop, and so forth. The class’s GetFolderPath method returns the full path for one of the special folders values. This program uses the following code to enumerate the … Continue reading

Posted in directories, files, system | Tagged , , , , , , , , , , , | 2 Comments

Create a directory and intermediate directories in C#

The System.IO.Directory class’s CreateDirectory method creates a directory. If the directory’s path includes missing intermediate directories, it creates them, too. For example, if C:\DirA is empty and you use CreateDirectory to create C:\DirA\DirB\DirC, then the method automatically creates DirB as … Continue reading

Posted in directories | Tagged , , , , , , , , , | 1 Comment

Let the user select a folder in C#

This example demonstrates two handy techniques. First, it lets you select a folder. When you click the program’s ellipsis button, the following code displays a FolderBrowserDialog. This lets the user pick a directory instead of needing to type it in. … Continue reading

Posted in directories, files, system | Tagged , , , , , , , , , , , , | Leave a comment

Number files in a directory in C#

I recently went on a trip where I took almost a thousand pictures. My phone (which has a pretty good camera) gives the pictures file names such as WP_20151106_22_04_47_Pro.jpg. I wanted an easy way to number files so they have … Continue reading

Posted in directories, files, system | Tagged , , , , , , , , , | Leave a comment

List Dropbox directories and files in C#

Dropbox is a file sharing service. The free Basic version lets you easily share up to 2 GB of files across the internet. The $9.99/month Pro version gives you up to 1 TB and the $15.00/month Business version gives you … Continue reading

Posted in directories, files, system, tools | Tagged , , , , , , , , , , , , , , | Leave a comment

Find, open, and replace text in files in C#

The example Find files and replace text in them in C# shows how you can find and replace text in files. This example modifies that one to let you open the files you find by double clicking on them in … Continue reading

Posted in directories, files, tools | Tagged , , , , , , , , , , , , , | Leave a comment

Find files and replace text in them in C#

This program lets you recursively find files in a directory hierarchy that match one or more patterns. You can then replace text in those files with new text. Both the Find and Find & Replace buttons call the SearchForFiles method. … Continue reading

Posted in directories, files, tools | Tagged , , , , , , , , , , , | 1 Comment

Test different methods that compare directories to see which files they have in common in C#

The example Compare directories to see which files they have in common in C# uses Directory.GetFiles to get the files in two directories. It sorts them and compares the two sorted lists to see which files are in the first … Continue reading

Posted in directories, files | Tagged , , , , , , , , , , , | 1 Comment

Compare directories to see which files they have in common in C#

This example compares directories to see which files they have in common and which files are only in one directory. When you click the Compare button, the following code executes. // Compare the files in each directory. private void btnCompare_Click(object … Continue reading

Posted in directories, files | Tagged , , , , , , , , , , , | 5 Comments