1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

指定した領域にディレクトリを作成するプログラム

1
Posted at

C#を使って新規のディレクトリを作成する方法

今回はC#を使った新規ディレクトリを作成するプログラムを制作しました

ソースコード


using System;
namespace ConsoleApplication1
{
class Sample
{
static void Main()
{
//Cドライブにtestのディレクトリを作ってその中にinディレクトリを作る
System.IO.DirectoryInfo di =
System.IO.Directory.CreateDirectory(@"C:\test\in");
}
}
}

結果

ディレクトリ作成.PNG

まとめ

System.IO名前空間のDirectoryクラスのCreateDirectoryメソッドを使うことで自分が指定した領域に新規でディレクトリを作成することができました。
このメソッドは親のディレクトリが存在しない場合には自動的に親のディレクトリを作成してくれます

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?