Автоматическое опознавание C# проксирует настройки

Грубая версия -

targetDir=. # adjust as needed
declare -i ctr=1
declare -a found=()
declare -l file
for file in [Vv][0]*            # refine this to get the files you want
do x=${file#v}                  # knock off the leading v
   while [[ "$x" =~ ^[0-9_-] ]] # if leading digits/dashes/underscores
   do x=${x:1}                  # strip them
   done
   found=( V${ctr}__* )         # check for existing enumerator
   while [[ -e "${found[0]}" ]] # if found
   do (( ctr++ ))               # increment
      found=( V${ctr}__* )      # and check again
   done
   mv "$file" "$targetDir/V${ctr}__$x" # move the file
done

Пожалуйста, прочтите, задайте вопросы и отредактируйте в соответствии с вашими потребностями.

23
задан Reinstate Monica 29 September 2011 в 08:50
поделиться

3 ответа

WebClient etc use the WinHTTP settings (not the IE settings), so the easiest thing to do is to configure WinHTTP! On XP etc you can use:

proxycfg -u

to import the current IE settings into the WinHTTP store. After that, WebClient etc should be able to use the same settings without issue. On Vista and Windows 7 this is now found under:

netsh winhttp import proxy ie

You need to run this as administrator.

5
ответ дан 29 November 2019 в 01:38
поделиться

Проверьте класс System.Net.Configuration.ProxyElement. Это может содержать информацию, которую вы ищете.

То, что вы описываете, работает, вы также можете посмотреть в реестре.

Вот сценарий PowerShell, который я написал для проверки прокси:

function get-proxy
{
    $path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
    $reg = get-itemproperty $path
    return $reg
}
2
ответ дан 29 November 2019 в 01:38
поделиться

Во-первых, GetDefaultProxy помечен как устаревший, поэтому у вас нет гарантии, что он будет работать даже в ближайшем будущем. Во-вторых, Адрес может иметь значение NULL, поэтому указанный вами код рискует вызвать исключение NullReferenceException:

4
ответ дан 29 November 2019 в 01:38
поделиться
Другие вопросы по тегам:

Похожие вопросы: