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


このメソッドから返される配列にファイル名やディレクトリ名としては無効なすべての文字が含まれるかどうかは、保証されません。無効な文字のセットは、ファイル システムにより異なります。たとえば、Windows ベースのデスクトップ プラットフォームでは、1 ~ 31 の ASCII 文字または Unicode 文字、および引用符 (")、不等号 (より小) (<)、不等号 (より大) (>)、パイプ (|)、バックスペース (\b)、null (\0)、タブ (\t) がパス文字として無効です。

パスを検証する GetInvalidFileNameChars メソッドおよび GetInvalidPathChars メソッドのコード例を次に示します。
Imports System Imports System.IO Module PathExample Sub Main() ' Get a list of invalid path characters. Dim invalidPathChars As Char() = Path.GetInvalidPathChars() Console.WriteLine("The following characters are invalid ina path:") ' Display each invalid character to the console. Dim invalidPChar As Char For Each invalidPChar In invalidPathChars Console.WriteLine(invalidPChar) Next invalidPChar ' Get a list of invalid file characters. Dim invalidFileChars As Char() = Path.GetInvalidFileNameChars() Console.WriteLine("The following characters are invalid ina path:") ' Display each invalid character to the console. Dim invalidFChar As Char For Each invalidFChar In invalidFileChars Console.WriteLine(invalidFChar) Next invalidFChar Console.ReadLine() End Sub End Module ' Note that while this code attempts to display a list of all invalid ' characters in paths and filenames, not all of the characters are ' within the displayable set of characters. Because the list of invalid ' characters can vary, based on the system, output for this code can vary.
using System; using System.IO; namespace PathExample { class GetCharExample { public static void Main() { // Get a list of invalid path characters. char[] invalidPathChars = Path.GetInvalidPathChars(); Console.WriteLine("The following characters are invalid in a path:"); // Display each invalid character to the console. foreach (char invalidPChar in invalidPathChars) { Console.WriteLine(invalidPChar); } // Get a list of invalid file characters. char[] invalidFileChars = Path.GetInvalidFileNameChars(); Console.WriteLine("The following characters are invalid in a filename:"); // Display each invalid character to the console. foreach (char invalidFChar in invalidFileChars) { Console.WriteLine(invalidFChar); } Console.ReadLine(); } } } // Note that while this code attempts to display a list of all invalid // characters in paths and filenames, not all of the characters are // within the displayable set of characters. Because the list of invalid // characters can vary, based on the system, output for this code can vary.
using namespace System; using namespace System::IO; int main() { // Get a list of invalid path characters. array<Char>^ invalidPathChars = Path::GetInvalidPathChars(); Console::WriteLine("The following characters are invalid in a path:"); // Display each invalid character to the console. for each (Char invalidPathChar in invalidPathChars) { Console::WriteLine(invalidPathChar); } // Get a list of invalid file characters. array<Char>^ invalidFileChars = Path::GetInvalidFileNameChars(); Console::WriteLine("The following characters are invalid in a file name:"); // Display each invalid character to the console. for each (Char invalidFileChar in invalidFileChars) { Console::WriteLine(invalidFileChar); } }

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に収録されているすべての辞書からPath.GetInvalidPathChars メソッドを検索する場合は、下記のリンクをクリックしてください。

- Path.GetInvalidPathChars メソッドのページへのリンク