// getfilename.cs
using System;
using System.IO;
public class GetFileName {
static void Main() {
string path1 = @"c:\windows\system32\notepad.exe";
string file1 = Path.GetFileName(path1);
Console.WriteLine(file1); // 出力例:notepad.exe
string path2 = "c:notepad.exe";
string file2 = Path.GetFileName(path2);
Console.WriteLine(file2); // 出力例:notepad.exe
string path3 = "http://www.atmarkit.co.jp/index.html";
string file3 = Path.GetFileName(path3);
Console.WriteLine(file3); // 出力例:index.html
}
}
0 件のコメント:
コメントを投稿