|
ok i need help here, I'VE LOST MY TUTORIAL IN MY BOOK, i want to send this "A2S_INFO" to a server through UDP/IP, How can i recieve his reply?
is this how to send?
System.Net.Sockets.UdpClient b = new System.Net.Sockets.UdpClient(serv, port);
b.Send(Encoding.UTF8.GetBytes("A2S_INFO"), Encoding.UTF8.GetBytes("A2S_INFO").GetLength(0));
|
|
|
|
|
hello developers... best regards!
I need to know how to get the data available in the dataGrid and insert (by a certain way) into sql server db?? i mean determining a datasource for the datagrid is simple, using a dataset, but if i wanna get this dataset and insert its data into a certain sql server table, how would it be?
Plz i need your help in that...
Ur help is much appreciated!
Sincerly urs, ali.;)
Knowledge Is KinG
|
|
|
|
|
hi
i want to print datagrid in vc# 2005 (not datagridview), and i found an article and class for datagridprinter in Codeproject but it's in VB and not work in c# .. does any one know how to do this ?
thanks ...
|
|
|
|
|
Hello
Maaybe you can check out this article[^]. DotNet 2.0 is a prerequisite on the target machine.
Regards
|
|
|
|
|
csc /t:module c:\form4.cs c:\form5.cs
when i use csc.exe through the command line this works and form4.netmodule is generated in
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
problem1:
the compiler always generates the .netmodule files in the above folder
how can i specify a path where i want to generate the .netmodule file
Problem2:
i am trying to do this through windows application(c#)
i am using this command on button_click
Process.Start(@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\\csc","/t:module c:\form4.cs c:\form5");
this command does not work properly
if there is some error in any file form4 or form5 it is indicated but when there is no error even then
the .netmodule file is not generated in the above mentioned folder
|
|
|
|
|
Hello,
you'll find CSC options in the MSDN documentation. /out specifies the output file, see: http://msdn2.microsoft.com/en-us/library/bw3t50f3.aspx
For compiling source code from within an application during runtime, I would suggest to make use of the System.CodeDom.Compiler classes (e.g. System.CodeDom.Compiler.CSharpCodeProvider) for compiling C#. There's also providers for other languages, unified under the ICodeCompiler interface (see MSDN).
Regards,
d.mon
|
|
|
|
|
I have a Client and a Sever, i connect the client to the server via Socket, now i'd like to send a file from the Client to the Server, i read about Socket.SendFile(fileName), but can't find how, from the server i have to receive the file using it (sendfile) in the client, i'd like to see an example, thank you!
|
|
|
|
|
Hy,
You don't need to send a file with the Send File method. The send method send a byte array. So use FileStream to read the byte content of the file and then send it to the client/server
FileStream fstream = File.Open(filename,FileMode.Open);
byte []buffer = new byte[fstream.Lenght];
fstream.Read(buffer,0,buffer.Length);
fstream.Close();
ClientSocket.Send(buffer);
It works fine on any kind of files. After you have received the file use FileStream to write the file (of course you should know the extension to put to the file).
Hope it helps
Do your best to be the best
|
|
|
|
|
I'm having problem in the Server Side;
How do i receive the file? and if i need the extension of the file, i have to send it with the client? and then how do i retrieve it? Thanks
else if (data.StartsWith("$UploadFile"))
{
}
|
|
|
|
|
You can create your own communication protocol. Let's say that the client sends a message to the server telling him that he will upload a file with a specified extension and size. The server sends back an acknowledge message and the the client sends the file.
Concerning the server. If you know the exact size of the file then you can do something like:
byte[] buffer = new byte[size];
client.Receive(buffer);
If you do not know the size of the file then you can write a sequence that reads data from the network in packets let's say 1024 long, like this:
ArrayList list = new ArrayList();
byte[] buffer = new byte[1024];
int read = 0;
int length = 0;
while ((read = client.Receive(buffer) != 0)
{
length += read;
list.Add(buffer);
buffer = new byte[1024];
if (read < 1024)
break;
}
At the end of this code you have inside the array list the entire file stored in 1024 length byte , arrays. After this just extract the byte arrays from the array list, like this.
buffer = new byte[length];
byte []temp = null;
int k = 0;
for (int i = 0 ; i < list.Count ; i++)
{
temp = (byte[])list[i];
for (int j = 0 ; j < temp.Length ; j++)
byte[k++] = temp[j];
}
Hope it helps.
Do your best to be the best
|
|
|
|
|
Ok, here is the Code, what's wrong?
//Client Side
FileStream fstream = File.Open(txtPathFile.Text, FileMode.Open);
byte[] buffer = new byte[fstream.Length];
fstream.Read(buffer, 0, buffer.Length);
fstream.Close();
Send("$UploadFile," + NameFileUpload.Remove(0, NomeFileUpload.ToString().LastIndexOf(@"\")).Remove(0, 1) + "," + buffer.Length + "|");
s.Send(buffer);
//Server Side
else if (data.StartsWith("$UploadFile"))
{
string[] b = data.Split(',');
string nameFile = b[1];
string size = b[2];
byte[] buffer = new byte[Int32.Parse(size)];
sock1.Receive(buffer);
File.WriteAllBytes(@"C:\" +nameFile, buffer);
}
|
|
|
|
|
Ok, here is the Code, what's wrong?
//Client Side
FileStream fstream = File.Open(txtPathFile.Text, FileMode.Open);
byte[] buffer = new byte[fstream.Length];
fstream.Read(buffer, 0, buffer.Length);
fstream.Close();
Send("$UploadFile," + NameFileUpload.Remove(0, NomeFileUpload.ToString().LastIndexOf(@"\")).Remove(0, 1) + "," + buffer.Length + "|");
s.Send(buffer);
//Server Side
else if (data.StartsWith("$UploadFile"))
{
string[] b = data.Split(',');
string nameFile = b[1];
string size = b[2];
byte[] buffer = new byte[Int32.Parse(size)];
sock1.Receive(buffer);
File.WriteAllBytes(@"C:\" +nameFile, buffer);
}
|
|
|
|
|
Please someone can help me?
|
|
|
|
|
my application shows an agent when it load
i would like when i right click on this agent it shows context menue
how can i do this
thank u
MD_NADA
|
|
|
|
|
I have just finished reading a book on C# and I would like to submit a review for it, but I can't find a link, is it the same as for submitting an article link?
|
|
|
|
|
Hello,
I am a noob to C# and would like to know the best method of parsing HTML. Here is an example of what I will be doing a lot of.
I would like to get the following variables
strVis = Detroit
intVisScore = 4
strHome = N.Y. Yankees
intHomeScore = 3
strInning = Final
strBoxScore = http://www.usatoday.com/sports/scores106/106278/MLB725547.htm
If you have something generic w/ good documentation I should be ok w/ that . I like learning the HOW.
Thanks!
Ryan
|
|
|
|
|
You can use a regular expression to parse the string.
As a lot of your example doesn't show up in the forum (as you haven't used the Ignore HTML feature), I can't really make a meaningful example from it. Here is an example from MSDN:
string text = "One car red car blue car";
string pat = @"(\w+)\s+(car)";
Regex r = new Regex(pat, RegexOptions.IgnoreCase);
Match m = r.Match(text);
int matchCount = 0;
while (m.Success)
{
Console.WriteLine("Match"+ (++matchCount));
for (int i = 1; i <= 2; i++)
{
Group g = m.Groups[i];
Console.WriteLine("Group"+i+"='" + g + "'");
CaptureCollection cc = g.Captures;
for (int j = 0; j < cc.Count; j++)
{
Capture c = cc[j];
System.Console.WriteLine("Capture"+j+"='" + c + "', Position="+c.Index);
}
}
m = m.NextMatch();
}
---
b { font-weight: normal; }
|
|
|
|
|
Could you enlighten me to the ignore HTML?
Thanks
|
|
|
|
|
You don't ignore the HTML, you use it to identify the information that you want.
If you have the string "...something...<table><tr><td>some info</td></tr></table>...something...", you can use the pattern "<table><tr><td>([^<]+)</td></tr></table>" to get the information.
---
b { font-weight: normal; }
|
|
|
|
|
Hi
I have I a class that inherits from TabConrol called MyControl. I have a class that inherits from TabPage called MyTabPage, as below:
(heavily simplified)
class MyTabControl:TabControl<br />
{<br />
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs ke)<br />
{<br />
(this.SelectedTab as MyTabPage).PanelContained.KDown(ke);<br />
base.OnKeyDown(ke);<br />
}<br />
}<br />
class MyTabPage : TabPage<br />
{<br />
private MyPanel panelContained;<br />
public MyPanel PanelContained{<br />
get { return panelContained; }<br />
set { panelContained = value; }<br />
}<br />
}
How can I override SelectedTab to return a MyTabPage? If I add a MyTabPage and change the panelcontained property, this is null again when I convet it back from SelectedTab.
Seeing as it inherits from TabControl is there a nice way to make it so that I can convert it back into a MyTabPage without losing the added property?
cheeers
|
|
|
|
|
thepersonof wrote: How can I override SelectedTab to return a MyTabPage?
You can't change the return type or the method parameter types in an overload.
thepersonof wrote: Seeing as it inherits from TabControl is there a nice way to make it so that I can convert it back into a MyTabPage without losing the added property?
<br />
TabControl tabs = new MyTabPage();
Since tab control does not have the PanelContained property you will not beable to use it in tabs
unless its cast back up to MyTabPage. Even though the compatible TabControl contains a MyTabPage the PanelContained property will not be exposed. You will have to do this.
<br />
((MyTabPage)tabs).PanelExposed<br />
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
Thank you. I can't manage to make the method you suggest work, does anyone have any other suggestions?
thanks
|
|
|
|
|
i have a folder inclodes some files
how can i read the file name from this folder
thankis for help
MD_NADA
|
|
|
|
|
You can use DirectoryInfo and FileInfo Class and then use getfiles method of directory ojbect to get all the files inside a particular directory. You can also use to to get a particular kind of file
DirectoryInfo dir = new DirectoryInfo(@"d:\skypak\text");<br />
FileInfo[] bmpfiles = dir.GetFiles("*.txt");
|
|
|
|
|
hello
how can i raise an event explicitly using coding for exemple i want to simulate the clicking in a tabpage of the tabcotrol so that it will be showed to the user
thank you! hope that understand what i mean !!
|
|
|
|