|
Thank you.
Learning Regular Expressions has been on my TODO list for some time, but somehow, something else always got in front of it in the waiting queue.
By the way, could you recommend a good resource for learning regex?
Thanks again.
|
|
|
|
|
blackjack2150 wrote: Thank you.
You're welcome.
blackjack2150 wrote: By the way, could you recommend a good resource for learning regex?
Oh, I'm not an expert about. I usually read MSDN (that usually is great), but IMHO Regex topic is not that good...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
for biginning of word use <[0-9]+
for biginning of line use ^[0-9]+
|
|
|
|
|
Hi,
I am using TCPClient for requesting web pages.
ex:
string Ahost = "http://www.Google.co.in";
Uri lastURI=new Uri(Ahost);
TcpClient client = new TcpClient();
string host = lastURI.Host;
string temp = lastURI.PathAndQuery;
client.Connect(host, lastURI.Port);
NetworkStream stream = client.GetStream();
string str = @"GET " + temp + " HTTP/1.1" + "\r\n" +
@"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*" + " \r\n" +
@"Accept-Language: en-us" + "\r\n" +
@"Accept-Encoding: gzip, deflate" + "\r\n" +
@"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)" + "\r\n" +
@"Host: " +host+ "\r\n" +
@"Connection: Keep-Alive" + "\r\n\r\n";
byte[] send = Encoding.ASCII.GetBytes(str);
try
{
if (stream.CanWrite)
{
stream.Write(send, 0, send.Length);
}
}
catch (System.IO.IOException ioe)
{
Console.WriteLine(ioe.Message);
}
byte[] bytesToRead = new byte[client.ReceiveBufferSize];
MemoryStream ms = new MemoryStream();
StringBuilder sbuild = new StringBuilder();
do
{
try
{
int numBytesRead = stream.Read(bytesToRead, 0, client.ReceiveBufferSize);
Console.WriteLine(numBytesRead.ToString());
ms.Write(bytesToRead, 0, numBytesRead);
Console.WriteLine(ms.Length);
}
catch (Exception e)
{
Console.WriteLine("No Data Found");
}
}while(stream.DataAvailable);
ms.Seek(0, 0);
StreamReader sr = new StreamReader(ms,Encoding.ASCII);
string Result = sr.ReadToEnd();
sr.Close();
ms.Close();
stream.Close();
client.Close();
Console.WriteLine(Result);
}
}
In the above case How can i use the same TCPClient object for more than one
request provided the host is same.(in case of requests like
http://www.google.co.in/
http://www.google.co.in/intl/en_com/images/logo_plain.png
http://www.google.co.in/images/nav_logo3.png )
Please Help
Sakthi.
|
|
|
|
|
string[] str1 = new string[3] { "http://www.google.co.in/", "http://www.google.co.in/intl/en_com/images/logo_plain.png", "http://www.google.co.in/images/nav_logo3.png" };
string Ahost = "http://www.Google.co.in";
Uri lastURI=new Uri(Ahost);
TcpClient client = new TcpClient();
string host = lastURI.Host;
client.Connect(host, lastURI.Port);
NetworkStream stream = client.GetStream();
for (int i = 0; i < str1.Length; i++)
{
string temp = new Uri(str1[i]).PathAndQuery;
string str = @"GET " + temp + " HTTP/1.1" + "\r\n" +
@"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*" + " \r\n" +
@"Accept-Language: en-us" + "\r\n" +
@"Accept-Encoding: gzip, deflate" + "\r\n" +
@"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)" + "\r\n" +
@"Host: " + host + "\r\n" +
@"Connection: Keep-Alive" + "\r\n\r\n";
byte[] send = Encoding.ASCII.GetBytes(str);
try
{
if (stream.CanWrite)
{
stream.Write(send, 0, send.Length);
}
}
catch (System.IO.IOException ioe)
{
Console.WriteLine(ioe.Message);
}
byte[] bytesToRead = new byte[client.ReceiveBufferSize];
MemoryStream ms = new MemoryStream();
StringBuilder sbuild = new StringBuilder();
do
{
try
{
int numBytesRead = stream.Read(bytesToRead, 0, client.ReceiveBufferSize);
Console.WriteLine(numBytesRead.ToString());
ms.Write(bytesToRead, 0, numBytesRead);
Console.WriteLine(ms.Length);
}
catch (Exception e1)
{
Console.WriteLine("No Data Found");
}
} while (stream.DataAvailable);
ms.Seek(0, 0);
StreamReader sr = new StreamReader(ms, Encoding.ASCII);
string Result = sr.ReadToEnd();
sr.Close();
ms.Close();
//stream.Close();
stream.Flush();
Console.WriteLine(Result);
}
client.Close();
|
|
|
|
|
Hi Subrata,
Actually in my case i may not know the URLs in advance.
If the host of requested url is same as the host of Previous Url
I should be able to use the same connection.
I tried the same without closing the underlying connection.
While reading for the next request,i am getting an exception as
Connection closed. Is it possible set the connection timeout.
Sakthi.
|
|
|
|
|
But please help
<code>string fullString = @"value1;value2;value3";
string []arString =
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi,
string[] arString=fullString.Split(';');
This will split your string.
Sakthi
|
|
|
|
|
I knew that was a terribly stupid question to ask
Thanks Sakthi
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
string[] arString = fullString.Split(';');
|
|
|
|
|
Thank you
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi
Please let me know why we are choosing C#.Net instead of VB.Net. What is the basic difference between these two. And Why C#.Net is more preferable than VB.Net. Thanks alot
Thanks and Regards
Venkat
|
|
|
|
|
|
venkatasivaramaprasad wrote: Please let me know why we are choosing C#.Net instead of VB.Net.
Well, not all of us are. Those who are, probably are because we came from C++. The only reason I know of to use C# is unsafe blocks. The reasons to avoid VB.NET include all sorts of nastiness, like hard to read code, 'magic' conversions that can really bite you when you don't expect them, and the VisualBasic namespace, which is full of rubbish imported from VB6.
But, if you know how to navigate the minefield that is VB.NET, the end code is basically going to run the same and do the same things.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
because vb is so ugly that when I look at some vb code I don't know whether to say "bue.." or "yuk!!"..
life is study!!!
|
|
|
|
|
Hi,
I am developing a chatting application with a Web Service as the central monitoring Server.
The Web Service methods will be used by the clients (Windows and Web) to Add User, Send and Recieve messages.
Can anyone help me in realizing this functionality as I have less knowledge on Web Service?
A sample code with this regard will also be helpful
Thanks in advance,
Murali
|
|
|
|
|
Ur Server code will have all the functionality of Add User, Send and Recieve messages. Then add a webservice to this server project. In the webservice add distinct WebMethods for each of ur task. Create a instance of the server inside this method and make an appropiate call.
ex. server.cs-
class server
{
AddUser(){}
}
in webservice.asmx
class service
{
[webmethod]
AddUserService()
{
server sr = new server();
sr.AddUser();
}
}
This example is just to help u to start. Once u start u can know how to invoke methods.
|
|
|
|
|
Thanks for the info.
Do you have a sample application on this regard?
Thanks in advance,
Murali
|
|
|
|
|
Hello everyone,
Here is my situation and I need your help guys. I have a loop to filter some data out of the DatGridView. I would like to assiagn each data to a specific TextBox (Five TextBox in total). The text boxs are names :
textBox1
textBox2
textBox3
textBox4
textBox5
Can someone be kind enough to tell me how I can assiagn each data to a textbox according to its index? This is what I mean:
for (int i = 1; i <= 5; i++)<br />
{<br />
textBox[i].Text = foundRows[i].ToString();<br />
}
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
do it in other ways.
TextBox tb[] = {textbox1,textbox2,...,textbox5};
for(i=0;i<5;i++)
{
tb[i].Text = foundRows[i].ToString();
}
|
|
|
|
|
Lets say these 5 buttons are placed on Form1. Than you can write this:
for(int i=1,i<6 i++)
{
Form1.Controls["textbox"+i.ToString()].Text=something;
}
|
|
|
|
|
Khoramdin wrote: textBox1
textBox2
textBox3
textBox4
textBox5
If you give them real names, they may make more sense. Then add a tag to each which is the same as the column you want to assign there, assuming they are columns from a single record. Then loop through the controls collection looking for the one with that tag.
Or you can create an array of textboxes.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I need to implement daemon functionality(which is available in java) in c# without using windows service and sql job. Please let me know if anyone has any idea about it.
|
|
|
|
|
Prajin wrote: without using windows service
Why, what is wrong with a Windows Service?
|
|
|
|
|
Hi,
I need to implement daemon functionality(which is available in java) in c#. Please let me know if anyone has any idea about it.
|
|
|
|