LoginSignup
0
0

More than 5 years have passed since last update.

[C#] パスからファイル名/ディレクトリ名の取得

Posted at

パスからファイル名/ディレクトリ名の取得方法メモ

パスからファイル名の取得
System.IO.Path.GetFileName(file_path)

System.IO.Path.GetFileName(@"C:\path\to\file.txt")
パスからディレクトリ名の取得
System.IO.Path.GetDirectoryName(file_path)

System.IO.Path.GetDirectoryName(@"C:\path\to\file.txt")

参考

Path.GetFileName メソッド (String) (System.IO)
Path.GetDirectoryName メソッド (String) (System.IO)
パスからファイル名、拡張子、ディレクトリ名、ルートディレクトリ名等の情報を取得する: .NET Tips: C#, VB.NET

0
0
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
0