Last active
September 11, 2015 10:55
-
-
Save ishisaka/5a6ab252f4d64c8979cb to your computer and use it in GitHub Desktop.
システムのプロキシー設定を取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// システムのプロキシー設定を表示する | |
// The MIT License (MIT) | |
// Copyright (c) 2015 Tadahiro Ishisaka. All Rights Reserved. | |
using System; | |
using System.Net; | |
namespace GetProxy | |
{ | |
internal class Program | |
{ | |
/// <summary> | |
/// エントリーポイント | |
/// </summary> | |
private static void Main() | |
{ | |
//var creds = System.Net.CredentialCache.DefaultCredentials; | |
var url = new Uri("http://opcdiary.net"); | |
var wc = new WebClient(); | |
var proxyaddress = "プロキシーサーバーはありません"; | |
// プロキシーサーバーが必要か確認し、必要であればプロキシーサーバーのアドレスを取得する | |
if (!wc.Proxy.IsBypassed(url)) | |
{ | |
// プロキシーサーバーのアドレスとポート番号を取得する。 | |
proxyaddress = wc.Proxy.GetProxy(url).Authority; | |
} | |
Console.WriteLine(proxyaddress); | |
//var proxy = new System.Net.WebProxy(proxyaddree); | |
//proxy.Credentials = creds; | |
//wc.Proxy = proxy; | |
Console.Read(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment