0
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 3 years have passed since last update.

C# 個人的によく使う変数等の備忘録

Last updated at Posted at 2021-08-04

すぐ忘れちゃうのでメモ

一覧

・デスクトップのパス

C#
string dsk = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

・フォルダの存在の確認と作成

C#
string path = @"C:\test1";
if (Directory.Exists(path))
{
       Console.WriteLine("存在します");
}
else
{
       Directory.CreateDirectory(path);
}

・ファイルの存在の確認と作成

C#
string path = @"C:\test\NewFile.txt";
if (File.Exists(path))
{
    Console.WriteLine("存在します");
}
else
{
    FileStream fileStream = File.Create(path);
}

メモ

随時書き足していってメモ代わり こうすると使いやすくなるよ!っていう書き方などあれば教えてくださいm(__)m また、同時に間違いなども指摘してもらえると嬉しいです(。-`ω-)
0
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
0
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?