Question

My messagebox shows listviewitem{'proxy'}. How can I filter out listviewitem { } to obtain only proxy string.

Codes will be...

for (int index = 0; index < listviewproxy.Items.Count; index++)
{
 ListViewItem proxyitem = listviewproxy.Items[index]; 
 string txturl = proxyitem.SubItems[0].Text;
 txturl = "Checking Url...";
 proxyitem.SubItems.Add(txturl);
 var RequestPage = BuildHttpRequest("http://www.google.com", listviewproxy.Items[index].ToString());
}

public static HttpWebRequest BuildHttpRequest(string url, string proxy)
{
 var getPage = (HttpWebRequest)WebRequest.Create(url);
 string occoultProxy = proxy;
 MessageBox.Show(proxy.ToString());
}

Was it helpful?

Solution

You can obtain the result by using IndexOf and Substring:

String St = proxy.ToString();
MessageBox.Show(St.Substring(0, St.LastIndexOf(':')).Substring(St.IndexOf('{') + 1));

It shows 96.8.114.186

OTHER TIPS

Just use the Text property,

listviewproxy.Items[index].Text
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top