using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

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

            #if DEBUG
                MinimizeBox = false;
            #else       
                MinimizeBox = true;
            #endif
        }

        DirectoryInfo rootInfo = new DirectoryInfo(@"\");
        string cardName = "";

 
        private void menuExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void menuWriteFile_Click(object sender, EventArgs e)
        {
            const string cardsTextFileName = "test.txt";
            const string textMessage = "Этот текст был записан на карточку памяти";

            string filePathName = Path.Combine(cardName,
                cardsTextFileName);

            StreamWriter writer = new StreamWriter(filePathName);
            writer.Write(textMessage);
            writer.Close();
            MessageBox.Show("Создан файл: " + filePathName);
        }

        private void menuFindCards_Click(object sender, EventArgs e)
        {
            int cardCount = 0;

            foreach (DirectoryInfo dirInfo in rootInfo.GetDirectories())
            {
                if ((dirInfo.Attributes & FileAttributes.Temporary) != 0)
                {
                    MessageBox.Show("Название флэш-карточки: " + dirInfo.FullName);
                    cardName = dirInfo.FullName;
                    cardCount++;
                }
            }

            string infoMessage = string.Format("Число флэш-карточек: {0}", cardCount.ToString());
            MessageBox.Show(infoMessage);
        }
    }
}