0

URIが有効な仮想パスであるかどうかを判断する機能はありますか?文字列が与えられ、文字列が有効な仮想パスでない場合、例外をスローせずにServer.MapPath()を使用する必要があります。

私の質問を閉じるために投票してください。答えは@ asp.netです-私のパスは仮想ですか?

4

1 に答える 1

0

メソッドを使用してFile.Exists() and Directory.Exists()、出力をチェックServer.MapPath()し、指定したパスにファイル/ディレクトリが存在することを確認できます。

Dim myPath as String = Server.MapPath('/some/path.aspx')
If File.Exists(myPath) Then
    //Do Something
Else
   If Directory.Exists(myPath) Then
       //Do Something
   Else
       //Invalid path
   End If
End If
于 2009-11-17T23:33:09.313 に答える