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

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

カレントドライブをj変更するには、Directory.SetCurrentDirectoryメッソッドを利用します。

using System.IO;

private void button1_Click(object sender, EventArgs e)
        {
           //カレントドライブをEに変更する
            Directory.SetCurrentDirectory("E:");

           string currentDrive;
           
           //カレントドライブを取得する
            currentDrive = Directory.GetCurrentDirectory().Substring(0, 1);
            MessageBox.Show(currentDrive, "カレントドライブ",
                MessageBoxButtons.OK, MessageBoxIcon.Information);
        }


▼ページトップへ