Directory.GetCurrentDirectory メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim returnValue As String returnValue = Directory.GetCurrentDirectory
現在の作業ディレクトリのパスを格納している文字列。


現在のディレクトリは、元のディレクトリとは異なり、プロセスが開始されたディレクトリです。
その他の一般的な I/O タスクまたは関連する I/O タスクの例を次の表に示します。
GetDirectories GetDirectories | |
GetFileSystemInfos | |
Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows CE プラットフォームメモ : 一部のモバイル デバイスのオペレーティング システムは "現在のディレクトリ" 機能を備えていないため、このメソッドがサポートされません。

GetCurrentDirectory メソッドのコード例を次に示します。
Imports System Imports System.IO Public Class Test Public Shared Sub Main() Try ' Get the current directory. Dim path As String = Directory.GetCurrentDirectory() Dim target As String = "c:\temp" Console.WriteLine("The current directory is {0}", path) If Directory.Exists(target) = False Then Directory.CreateDirectory(target) End If ' Change the current directory. Environment.CurrentDirectory = (target) If path.Equals(Directory.GetCurrentDirectory()) Then Console.WriteLine("You are in the temp directory.") Else Console.WriteLine("You are not in the temp directory.") End If Catch e As Exception Console.WriteLine("The process failed: {0}", e.ToString()) End Try End Sub End Class
using System; using System.IO; class Test { public static void Main() { try { // Get the current directory. string path = Directory.GetCurrentDirectory(); string target = @"c:\temp"; Console.WriteLine("The current directory is {0}", path); if (!Directory.Exists(target)) { Directory.CreateDirectory(target); } // Change the current directory. Environment.CurrentDirectory = (target); if (path.Equals(Directory.GetCurrentDirectory())) { Console.WriteLine("You are in the temp directory."); } else { Console.WriteLine("You are not in the temp directory."); } } catch (Exception e) { Console.WriteLine("The process failed: {0}", e.ToString()); } } }
using namespace System; using namespace System::IO; int main() { try { // Get the current directory. String^ path = Directory::GetCurrentDirectory(); String^ target = "c:\\temp"; Console::WriteLine( "The current directory is {0}", path ); if ( !Directory::Exists( target ) ) { Directory::CreateDirectory( target ); } // Change the current directory. Environment::CurrentDirectory = target; if ( path->Equals( Directory::GetCurrentDirectory() ) ) { Console::WriteLine( "You are in the temp directory." ); } else { Console::WriteLine( "You are not in the temp directory." ); } } catch ( Exception^ e ) { Console::WriteLine( "The process failed: {0}", e ); } }
import System.*; import System.IO.*; class Test { public static void main(String[] args) { try { // Get the current directory. String path = Directory.GetCurrentDirectory(); String target = "c:\\temp"; Console.WriteLine("The current directory is {0}", path); if (!(Directory.Exists(target))) { Directory.CreateDirectory(target); } // Change the current directory. Environment.set_CurrentDirectory(target); if (path.Equals(Directory.GetCurrentDirectory())) { Console.WriteLine("You are in the temp directory."); } else { Console.WriteLine("You are not in the temp directory."); } } catch (System.Exception e) { Console.WriteLine("The process failed: {0}", e.ToString()); } } //main } //Test


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDirectory.GetCurrentDirectory メソッドを検索する場合は、下記のリンクをクリックしてください。

- Directory.GetCurrentDirectory メソッドのページへのリンク