Tag Archives: directories

New Book: The Modern C# Challenge

My latest book, The Modern C# Challenge, is now available. It’s a collection of 100 programming challenges that let you test your ability in a wide variety of programming topics, many of which are not usually covered in traditional programming … Continue reading

Posted in algorithms, books, files, mathematics, puzzles | Tagged , , , , , , , , , , , , , , , , , , , , , , , | 1 Comment

Merge directories in C#

This example lets you merge directories. Once upon a time, if you used Windows Explorer to move a file from one directory to another and the destination directory already contained a file with that name, you had the option of … Continue reading

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

Compress and decompress directories in C#

The ZipFile class provides remarkably simple methods to compress and decompress directories in the zip format. This class is defined in the .NET Framework version 4.5, so this example is in Visual Studio 2017 instead of an older version. To … Continue reading

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

Use Word to make a PDF containing pictures in C#

The example Make a Word document containing pictures in C# shows how to make a Word document containing pictures taken from selected files. This example is similar to the that one (see that post for details) except it saves the … Continue reading

Posted in files, graphics, interoperability, Office, Word | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Make a Word document containing pictures in C#

Occasionally you may want to combine selected pictures to make a Word document. This example shows one way you can search for files matching a pattern and then add them to a new Word document. This is a fairly long … Continue reading

Posted in files, graphics, interoperability, Office, Word | Tagged , , , , , , , , , , , , , , | 3 Comments

Initialize a TreeView control to display a directory hierarchy in C#

This example adds the following LoadFromDirectory extension method to the TreeView control. // Initialize the TreeView from a directory, // its subdirectories, and their files. public static void LoadFromDirectory(this TreeView trv, string directory, int folder_img, int file_img) { DirectoryInfo dir_info … Continue reading

Posted in controls, directories, extension methods, files, user interface | Tagged , , , , , , , , , , , , , | Leave a comment

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