A directory is a section of a medium used to delimit a group
of files. Because it is a "physical" area, it can handle operations
not available on files. In fact, there are many fundamental differences between
both:

A file is used to contain data. A directory doesn't contain data

A directory can contain one or more files and not vice-versa

A directory can contain other directories

A file can be moved from one directory to another. This operation is not
possible vice-versa since a file cannot contain a directory

The similarities of both types are:

A directory or a file can be created. One of the restrictions is that two
files cannot have the same name inside of the same directory. Two
directories cannot have the same name inside of the same parent directory.

A directory or a file can be renamed. If a directory is renamed, the
"path" of its file(s) changes

A directory or a file can be deleted. If a directory is deleted, its files
are deleted also

A directory or a file can be moved. If a directory moves, it
"carries" all of its files to the new location

A directory or a file can be copied. A file can be copied from one
directory to another. If a directory is copied to a new location, all of its
files are also copied to the new location

Before using a directory, you must first have it. You can
use an existing directory if the operating system or someone else had already
created one. You can also create a new directory. Directories are created and
managed by various classes but the fundamental class is Directory.
Directory is an abstract and sealed class. All of its methods are static, which
means you will never need to declare an instance of the Directory class in order
to use it.

Besides the Directory class, additional operations of
folders and sub-folders can be performed using the DirectoryInfo class.

To create a directory, you can call the CreateDirectory()
method of the Directory class. This method is available in two versions.
One of the versions uses the following syntax:

public:
static DirectoryInfo ^ CreateDirectry(String ^path);

This method takes as argument the (complete) path of the
desired directory. Here is an example:

E:\Programs\Business Orders\Customer Information

When this method is called:

It first checks the parent drive, in this case E.
If the drive doesn't exist, because this method cannot create a drive, the
compiler would throw a DirectoryNotFoundException exception

If the drive (in this case E) exists, the compiler moves to the first
directory part of the path; in this case this would be the Programs folder
in the E drive.
If the folder doesn't exist, the compiler would create it. If that first
director doesn't exist, this means that the other directory(ies), if any,
under the first don't exist. So, the compiler would create it/them

If the first directory exists and if there is no other directory under
that directory, the compiler would stop and would not do anything further.

If the directory exists and there is a sub-directory specified under it,
the compiler would check the existence of that directory.
If the sub-directory exists, the compiler would not do anything further and
would stop.
If the sub-directory doesn't exist, the compiler would create it

The compiler would repeat step 4 until the end of the specified path

The Directory::CreateDirectory() method returns a DirectoryInfo
object that you can use as you see fit.

Checking for a Directory Existence

Before using or creating a directory, you can first check if
it exists. This is because, if a directory already exists in the location where
you want to create it, you would be prevented from creating one with the same
name. In the same way, if you just decide to directly use a directory that
doesn't exist, the operation you want to perform may fail because the directory
would not be found.

Before using or creating a directory, to first check whether
it exists or not, you can call the Directory::Exists() Boolean method. Its
syntax is:

public:
static bool Exists(String ^path);

This method receives the (complete) path of the directory.
If the path exists, the method returns true. If the directory doesn't exist, the
method returns false.

To create a directory, you can call the CreateDirectory()
method of the Directory class.

Locating a File

One of the most routine operations performed in a directory
consists of looking for a file. Both Microsoft Windows operating systems and the
user's intuition have different ways of addressing this issue. The .NET Framework
also provides its own means of performing this operation, through various
techniques. You can start by checking the sub-directories and files inside of a
main directory.

To look for files in a directory, the DirectoryInfo
class can assist you with its GetFiles() method, which is overloaded with
three versions.

Practical
Learning: Using Directories and Files

To create a new class, in the Class View, right-click
GeorgetownCleaningOrder6 -> Add -> Class...

Is this a new order or the customer is retrieving
items previously left for cleaning?
0. Quit
1. This is a new order
2. The customer is retrieving an existing order
Your Choice: 0
Press any key to continue . . .

Close the DOS window

Execute the application and create a new order. Here is an example:

Is this a new order or the customer is retrieving
items previously left for cleaning?
0. Quit
1. This is a new order
2. The customer is retrieving an existing order
Your Choice: 1
-/- Georgetown Cleaning Services -/-
Enter Customer Phone Number: 202 103 0443
It looks like this is the first time you are trusting
us with your cleaning order
Enter Customer Name: Arsene Cranston
Enter the order date(mm/dd/yyyy): 11/20/2007
Enter the order time(hh:mm AM/PM): 08:12 AM
Number of Shirts: 6
Number of Pants: 4
Number of Other Items: 2
The Total order is: $28.13
Amount Tended? 30
====================================
-/- Georgetown Cleaning Services -/-
====================================
Customer: Arsene Cranston
Home Phone: 2021030443
Order Date: Tuesday, November 20, 2007
Order Time: 8:12 AM
------------------------------------
Item Type Qty Unit/Price Sub-Total
------------------------------------
Shirts 6 0.95 5.70
Pants 4 2.95 11.80
Other Items 2 4.55 9.10
------------------------------------
Total Order: $26.60
Tax Rate: 5.75 %
Tax Amount: $1.53
Net Price: $28.13
------------------------------------
Amount Tended: $30.00
Difference: $1.87
====================================
Press any key to continue . . .

Remember the date you provided and close the DOS window

Execute the application and create a new order. Here is an example:

Is this a new order or the customer is retrieving items
previously left for cleaning?
0. Quit
1. This is a new order
2. The customer is retrieving an existing order
Your Choice: 1
-/- Georgetown Cleaning Services -/-
Enter Customer Phone Number: 301-022-1077
It looks like this is the first time you are trusting
us with your cleaning order
Enter Customer Name: Helene Craft
Enter the order date(mm/dd/yyyy): 11/21/2007
Enter the order time(hh:mm AM/PM): 9:25
Number of Shirts: 3
Number of Pants: 0
Number of Other Items: 5
The Total order is: $27.07
Amount Tended? 40
====================================
-/- Georgetown Cleaning Services -/-
====================================
Customer: Helene Craft
Home Phone: 3010221077
Order Date: Wednesday, November 21, 2007
Order Time: 9:25 AM
------------------------------------
Item Type Qty Unit/Price Sub-Total
------------------------------------
Shirts 3 0.95 2.85
Pants 0 2.95 0.00
Other Items 5 4.55 22.75
------------------------------------
Total Order: $25.60
Tax Rate: 5.75 %
Tax Amount: $1.47
Net Price: $27.07
------------------------------------
Amount Tended: $40.00
Difference: $12.93
====================================
Press any key to continue . . .

Remember the date you provided and close the DOS window

Execute the application and choose to open an existing order. Here is an example: