重複の可能性:
C# で URI 文字列からファイル名を取得する
C#でUriからファイル名を抽出するには?
たとえば、私は Uri を持っています
"http://audacity.googlecode.com/files/audacity-win-2.0.exe"
しかし、ファイル名を抽出する方法
"audacity-win-2.0.exe"
文字列として保存しますか?
ありがとうございました、
ジェリー
重複の可能性:
C# で URI 文字列からファイル名を取得する
C#でUriからファイル名を抽出するには?
たとえば、私は Uri を持っています
"http://audacity.googlecode.com/files/audacity-win-2.0.exe"
しかし、ファイル名を抽出する方法
"audacity-win-2.0.exe"
文字列として保存しますか?
ありがとうございました、
ジェリー
Path.GetFileName
出来る...
Uri u = new Uri("http://audacity.googlecode.com/files/audacity-win-2.0.exe");
Path.GetFileName(u.AbsolutePath);
どうですか
Path.GetFileName(string path);
あなたの場合
Path.GetFileName(new Uri("http://audacity.googlecode.com/files/audacity-win-2.0.exe").AbsolutePath);
例えば
Uri uri = new Uri("http://audacity.googlecode.com/files/audacity-win-2.0.exe");
string Path.GetFileName(uri.AbsolutePath);
aが常に物理ファイルを表すと想定するのは安全ではないため、URI
aからファイル名を抽出することURI
が常に保証されるわけではありません。