---
title: "How to get proxy from text file c#/.net?"  
description: "How to get proxy from text file c#/.net?"  
author: "Takeshi Okada"  
published: 2014-02-03  
updated: 2014-02-03  
canonical: https://www.mindstick.com/forum/1945/how-to-get-proxy-from-text-file-c-sharp-dot-net  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How to get proxy from text file c#/.net?

I have saved some [url](https://www.mindstick.com/forum/436/url-redirection)'s in a text(link.txt) file &[amp](https://www.mindstick.com/forum/156207/what-is-amp); some [proxy](https://www.mindstick.com/interview/803/what-is-the-proxy-for-wcf-service)(proxy.txt) in another [text file](https://www.mindstick.com/forum/12828/converting-a-text-file-to-an-array-in-java).

[now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now) i want to use different proxy for each url.

like:

www.google.com 202.56.232.117:8080

www.facebook.com 506.78.781.987:9001

www.twitter.com 749.961.73.459:8008

this is my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) but i don't know how to use different proxy(proxy.txt) for each url.

[please tell me](https://www.mindstick.com/forum/33900/please-tell-me-what-are-the-technique-to-content-optimization) how to make this work.

```
try{    foreach (string sr in File.ReadAllLines("link.txt"))    {        webBrowser1.Navigate(sr);    }    webBrowser1.ScriptErrorsSuppressed = true;    while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)    {        Application.DoEvents();    }}catch(Exception){     MessageBox.Show("Internet Connection not found","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);     this.Close();}
```

## Replies

### Reply by Pravesh Singh

Hi Takeshi,\

try this:

```
Public Sub SetProxy(ByVal ServerName As String, ByVal port As Integer)Try            Dim regkey1 As RegistryKeyregkey1 =Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet
Settings", True)regkey1.SetValue("ProxyServer", ServerName +
":" + port.ToString(), RegistryValueKind.Unknown)regkey1.SetValue("ProxyEnable", True,
RegistryValueKind.DWord)   regkey1.Close()Catch ex As ExceptionEnd TryEnd Sub
```


---

Original Source: https://www.mindstick.com/forum/1945/how-to-get-proxy-from-text-file-c-sharp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
