Ra Mi

hey ,
im a newbie user in C# programmig , ok

now take a look at this link

http://www.lyrics007.com/Stacie%20Orrico%20Lyrics/Dear%20Friend%20Lyrics.html

now im trying to create a project that the user will just enter the artist name and the song title then the program will automatically put them in their right places in the link
for example :
artist : stacie orrico
song title : dear friend

the the link will be :
http://www.lyrics007.com/Stacie%20Orrico%20Lyrics/Dear%20Friend%20Lyrics.html

got it

well that's my code

===========================

class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter the artist name");
string artist = Console.ReadLine();
artist = artist.Replace(" ", "%20");
Console.WriteLine("Please enter the song title");
string song = Console.ReadLine();
song = song.Replace(" ", "%20");
Console.WriteLine("the link is");
Console.WriteLine("http://www.lyrics007.com/"+artist+"%20Lyrics/"+song+"%20Lyrics.html");
Console.ReadLine();
}
}

========================

by this code , everything is ok but 1 bug :

now when the user enter the name of the artist "stacie orrico" and the song title "dear friend"

then the link will be :
http://www.lyrics007.com/stacie%20orrico%20Lyrics/dear%20friend%20Lyrics.html

but the link should be :
http://www.lyrics007.com/Stacie%20Orrico%20Lyrics/Dear%20Friend%20Lyrics.html

( the names and the song titles must begin by a capital letter )

HOW CAN I FIX THIS BUG

....

another question ..
how would i make the project go to the created link

thx in advance :)
Rami


Re: Visual C# General lyrics finder problem

Mark Betz

Your first problem is pretty much a textbook application for regular expression replacement. See the following for an example that does exactly what you want.

http://msdn2.microsoft.com/en-us/library/cft8645c.aspx

The second problem, how to "make the project go to the created link," is a little more involved. If you really want to do it from a console application, then you will need to launch IE from the console app...

System.Diagnostics.ProcessStartInfo start = new System.Diagnostics.ProcessStartInfo("IExplore.exe");
start.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
start.Arguments = ¡°http://www.lyrics007.com/Stacie%20Orrico%20Lyrics/Dear%20Friend%20Lyrics.html ¡°;
System.Diagnostics.Process.Start(start);

Otherwise, if you are creating a web application then it is just a matter of Response.Redirect. If you are creating a Forms application then you can create an instance of the WebBrowser and navigate it to the URL using the Navigate() method.

Hope this helps.





Re: Visual C# General lyrics finder problem

Marcelo Guerra - MSFT

Hi,

For the frist problem: Are you sure that you need to capitalize the first letter I can navigate to 

http://www.lyrics007.com/stacie%20orrico%20Lyrics/dear%20friend%20Lyrics.html

without problem.

For the second you don't actually need to specify iexplorer. A line like this will do the work:

Process.Start("http://live.com");