Path.GetFileNameWithoutExtension メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
オーバーロード
| 名前 | 説明 |
|---|---|
| GetFileNameWithoutExtension(ReadOnlySpan<Char>) |
読み取り専用の文字スパンで表されるファイル パスの拡張子を持たないファイル名を返します。 |
| GetFileNameWithoutExtension(String) |
指定したパス文字列のファイル名を拡張子なしで返します。 |
GetFileNameWithoutExtension(ReadOnlySpan<Char>)
- ソース:
- Path.cs
- ソース:
- Path.cs
- ソース:
- Path.cs
- ソース:
- Path.cs
- ソース:
- Path.cs
読み取り専用の文字スパンで表されるファイル パスの拡張子を持たないファイル名を返します。
public:
static ReadOnlySpan<char> GetFileNameWithoutExtension(ReadOnlySpan<char> path);
public static ReadOnlySpan<char> GetFileNameWithoutExtension(ReadOnlySpan<char> path);
static member GetFileNameWithoutExtension : ReadOnlySpan<char> -> ReadOnlySpan<char>
Public Shared Function GetFileNameWithoutExtension (path As ReadOnlySpan(Of Char)) As ReadOnlySpan(Of Char)
パラメーター
- path
- ReadOnlySpan<Char>
拡張子のないファイル名を取得するパスを含む読み取り専用スパン。
返品
GetFileName(ReadOnlySpan<Char>)によって返される読み取り専用スパン内の文字から最後のピリオド (.) とその後のすべての文字を引いた文字。
こちらもご覧ください
適用対象
GetFileNameWithoutExtension(String)
- ソース:
- Path.cs
- ソース:
- Path.cs
- ソース:
- Path.cs
- ソース:
- Path.cs
- ソース:
- Path.cs
指定したパス文字列のファイル名を拡張子なしで返します。
public:
static System::String ^ GetFileNameWithoutExtension(System::String ^ path);
public static string GetFileNameWithoutExtension(string path);
public static string? GetFileNameWithoutExtension(string? path);
static member GetFileNameWithoutExtension : string -> string
Public Shared Function GetFileNameWithoutExtension (path As String) As String
パラメーター
- path
- String
ファイルのパス。
返品
GetFileName(ReadOnlySpan<Char>)によって返される文字列。最後のピリオド (.) とその後のすべての文字を差し引いた文字列。
例外
.NET Framework および .NET Core バージョン 2.1 より前: path には、 GetInvalidPathChars()で定義されている無効な文字が 1 つ以上含まれています。
例
次の例では、 GetFileNameWithoutExtension メソッドの使用方法を示します。
string fileName = @"C:\mydir\myfile.ext";
string path = @"C:\mydir\";
string result;
result = Path.GetFileNameWithoutExtension(fileName);
Console.WriteLine("GetFileNameWithoutExtension('{0}') returns '{1}'",
fileName, result);
result = Path.GetFileName(path);
Console.WriteLine("GetFileName('{0}') returns '{1}'",
path, result);
// This code produces output similar to the following:
//
// GetFileNameWithoutExtension('C:\mydir\myfile.ext') returns 'myfile'
// GetFileName('C:\mydir\') returns ''
Dim fileName As String = "C:\mydir\myfile.ext"
Dim pathname As String = "C:\mydir\"
Dim result As String
result = Path.GetFileNameWithoutExtension(fileName)
Console.WriteLine("GetFileNameWithoutExtension('{0}') returns '{1}'", fileName, result)
result = Path.GetFileName(pathname)
Console.WriteLine("GetFileName('{0}') returns '{1}'", pathname, result)
' This code produces output similar to the following:
'
' GetFileNameWithoutExtension('C:\mydir\myfile.ext') returns 'myfile'
' GetFileName('C:\mydir\') returns ''
注釈
このメソッドは、パスまたはファイル名が存在することを確認しません。
一般的な I/O タスクの一覧については、「 一般的な I/O タスク」を参照してください。