2 Replies - 1225 Views - Last Post: 24 January 2010 - 09:17 PM

#1 gibson_junk   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 95
  • Joined: 24-July 09

C++/CLI need some help with little code

Posted 23 January 2010 - 04:31 PM

Ok so i have been asking alot of questions here but i learn better asking like this then reading a boring book. So far i think i am catching on very well. Now i have another question though.

I updated the code but does not work for some reason. Now i compile with now errors But this code does not read the html from the website But if i use this other code it does.

Not working code here. scroll down for the working code

static String^ HTTPRequest(String^ URL){
				Uri^ url = gcnew Uri( URL );
				HttpWebRequest^ request = dynamic_cast<HttpWebRequest^>(WebRequest::Create(url));
				HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(request->GetResponse());
				StreamReader^ reader = gcnew StreamReader(response->GetResponseStream());
				String^ tmp = reader->ReadToEnd();
				response->Close();

				return tmp;
		}
		
		static void GetStats(String^ RSI){
			String^ tmp = HTTPRequest("http://beta.rapidpremium.net/");
			String^ info = String::Empty;
				int Get_I = 0;

				//RapidShare Info
				Get_I = tmp->IndexOf("<center>We have");

				Get_I = tmp->IndexOf("<center>",Get_I);
				tmp = tmp->Substring(Get_I + 8);
				info = tmp->Substring(0,tmp->IndexOf("<br />"));
				RSI = info;
		}




Working code here.

Uri^ url = gcnew Uri("http://beta.rapidpremium.net/");
				HttpWebRequest^ request = dynamic_cast<HttpWebRequest^>(WebRequest::Create(url));
				HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(request->GetResponse());
				StreamReader^ reader = gcnew StreamReader(response->GetResponseStream());
				String^ tmp = reader->ReadToEnd();
				response->Close();
				String^ info = String::Empty;
				int Get_I = 0;

				//RapidShare Info
				Get_I = tmp->IndexOf("<center>We have");

				Get_I = tmp->IndexOf("<center>",Get_I);
				tmp = tmp->Substring(Get_I + 8);
				info = tmp->Substring(0,tmp->IndexOf("<br />"));
				RSinfo->Text = info;
]

This post has been edited by gibson_junk: 23 January 2010 - 05:20 PM


Is This A Good Question/Topic? 0
  • +

Replies To: C++/CLI need some help with little code

#2 manzoor   User is offline

  • D.I.C Regular
  • member icon

Reputation: 13
  • View blog
  • Posts: 468
  • Joined: 07-August 07

Re: C++/CLI need some help with little code

Posted 24 January 2010 - 08:43 PM

Can you post the errors you are encountering?
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: C++/CLI need some help with little code

Posted 24 January 2010 - 09:17 PM

gibson_junk, you've been here long enough to know to post better, more meaningful titles than "Need Some Help With Little Code" (Duh, isn't that why pretty much everyone comes here???) and to post some code saying "this doesn't work" with no further explanation.

You should actually spend some time reading the link in manzoor's sig.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1