Грубая версия -
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
Пожалуйста, прочтите, задайте вопросы и отредактируйте в соответствии с вашими потребностями.
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.
Проверьте класс System.Net.Configuration.ProxyElement. Это может содержать информацию, которую вы ищете.
То, что вы описываете, работает, вы также можете посмотреть в реестре.
Вот сценарий PowerShell, который я написал для проверки прокси:
function get-proxy
{
$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
$reg = get-itemproperty $path
return $reg
}
Во-первых, GetDefaultProxy помечен как устаревший, поэтому у вас нет гарантии, что он будет работать даже в ближайшем будущем. Во-вторых, Адрес может иметь значение NULL, поэтому указанный вами код рискует вызвать исключение NullReferenceException: