Domanda

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());
}

È stato utile?

Soluzione

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

Altri suggerimenti

Just use the Text property,

listviewproxy.Items[index].Text
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top