Test File and Directory



Files and Streams

This program demonstrates files and streams in C#. Double click a file to stream it.

Here's the code!

                            using System;
                            using System.Windows.Forms;
                            using System.IO;

                            namespace TestFileAndDirectory
                            {
                                public partial class Form1 : Form
                                {
                                    public Form1()
                                    {
                                        InitializeComponent();
                                    }

                                    private void Form1_Load(object sender, EventArgs e)
                                    {
                                        string directoryName;
                                        directoryName = @"C:\Users\Benjamin_Schneider\Documents\Visual Studio 2013\Projects\CH14Labs\TestFileAndDirectory2\bin\Debug\new folder";
                                        string[] listOfFiles;
                                        listOfFiles = Directory.GetFiles(directoryName);
                                        for (int x = 0; x < listOfFiles.Length; ++x)
                                        {
                                            checkedListBox1.Items.Add(listOfFiles[x]);
                                        }
                                    }

                                    private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
                                    {
                                        string itemCheck = Convert.ToString(checkedListBox1.SelectedItem);
                                        theLabel.Text += itemCheck + " was created " + File.GetCreationTime(itemCheck) + "\n";
                                    }
                                }
                            }