[VC2005] カレントドライブを取得する方法

◆概要
この資料は、Microsoft(R) Visual C# 2005で カレントドライブを取得する方法について記述しています。

◆Directory.GetCurrentDirectoryメッソッド

カレントドライブを取得するには、Directory.GetCurrentDirectoryメッソッドを利用します。

using System.IO;

private void button1_Click(object sender, EventArgs e)
        {
           //カレントドライブを取得するために
            //Directory.GetCurrentDirectoryメソッドを利用します
            string currentDrive;

            currentDrive = Directory.GetCurrentDirectory().Substring(0, 1);

            MessageBox.Show(currentDrive, "カレントドライブ",
                  MessageBoxButtons.OK, MessageBoxIcon.Information);
        }


▼ページトップへ