アプリの画像を読み込みたい。画像を取得するために必要な正確な URL を知っています。URLが存在するかどうかを確認する方法は?
1 に答える
            0        
        
		
このようなものを使用します。
bool result = false;
    using (WebClient client = new WebClient())
    {
        try
        {
            Stream stream = client.OpenRead(url);
            if (stream != null)
            {
                result = true;
            }
            else
            {
                result = false;
            }
        }
        catch
        {
            //Any exception will returns false.
            result = false;
        }
    }
    return result;
WP7 を使用しているため、非同期バージョンを確認する必要がある場合があります。
ソース: http://www.dotnetthoughts.net/how-to-check-remote-file-exists-using-c/
于 2013-08-22T04:41:38.310   に答える