|
Hi,
How to remove/delete any particular file from any particular folder/directory?
Thank you in advance
(Riaz)
|
|
|
|
|
System.IO.File.Delete(strFileName)
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
|
Hi,
I have created one form containing some controls like buttons, textbox, labels and all, and i want to write the Event Handler for some controls in a different class file.I am using C# windows application. How to do that???
Rakesh B.P.
|
|
|
|
|
By default event handler will be added in the same class file. So if you need to write event handler method in your other class, modify event handler reference in InitializeComponent() method to your new class.
EventHandlerClass EventHandler = new EventHandlerClass ();
this.button1.Click += new System.EventHandler(EventHandler.button1_Click);
Why you want to split your event handler code to other class ?
If you are using .NET 2005, then you can make use of partial classes. Class name will be same, but you can keep the events in separate file.
Other way is using delegates.
|
|
|
|
|
Hi,
I have a big class with plenty of methods. But some of the methods inside this is not using now. So all these methods has to be removed which have no refernce. Is there any way to know which are the methods that is not having reference ?
|
|
|
|
|
You can right click on the method and choose 'find all references' ( from memory ) it finds all the places that call a function. Or you can just search the solution for the function name. Dong it for all in one go, not that I know of.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Christian Graus wrote: You can right click on the method and choose 'find all references' ( from memory ) it finds all the places that call a function.
Thanks Christian. This what I am doing now. But it takes lot of time. And I have got lot of function to go. So I thought any way to list all the unreferenced functions. Do you know about Redgate profiler ? will that help on this issue ?
|
|
|
|
|
How do you close a C# application with more than one form? I can close the forms but the application keeps running in the task manager's processes. Can anyone help me out ?
Girish Soni
|
|
|
|
|
sonigirish wrote: I can close the forms but the application keeps running in the task manager's processes. Can anyone help me out?
You have to close the main form(where main() function resides). Once you close the main form, it will be removed from process list.
|
|
|
|
|
Thanks for reply I am having two forms when i click button on form1 then form1 will close and form2 will open. I want to close application by clicking on button on form2.
Girish Soni
|
|
|
|
|
sonigirish wrote: i click button on form1 then form1 will close and form2 will open. I want to close application by clicking on button on form2.
In which form your main() method resides ? How you are closing form1 when form2 is open ? Are you just hiding form1 when form2 shows ?
|
|
|
|
|
My main method is in program.cs and my first form is form1 and on button click event code is
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Form2 frm = new Form2() ;
frm.Show() ;
}
I want to close application on form2' button click ie button2-Click event
Girish Soni
|
|
|
|
|
sonigirish wrote: I want to close application on form2' button click ie button2-Click event
Write a method in your first form which closes that form. Using delegates, call this method when form2 is closed. This will close your entire APP.
Alternatively, you can pass form1 object to form2 constructor, and dispose this object when form2 closed.
|
|
|
|
|
hi
u can use Application.Exit() where evr u plan to terminate the application. for eg. if after showing form1 u want to close it, then on lets say btnExit_click event, u can use Application.Exit() to close the entire application and this would also remove the application thread from the task manager. This method basically terminates the application domain which the application is running in.Hope this would help.
Cheers
|
|
|
|
|
If your app is running with all forms closed, you must have a thread running. What if you debug, close all and hit the break menu item to see where the code is ?
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Use Application.End() function it will close the application
with regards
yogesh agarwal
|
|
|
|
|
You mean Application.Exit() ?
|
|
|
|
|
hi all and thanks for trying to help ,
currently im working on a project wich involves a multi threaded server
and a client program .
can anyone advice me of a common method which i could retreive with my client program an updated list of users online on my server , which keep updating once user left the server or a new user has joined the server ,
i mean many online games or applications have something like that , i would like to know how to do it , any advice would be great thanks.
Net
|
|
|
|
|
When any user update in a server list then server send an event to client with updated list and then update the client list.
Clien hold the Remote server object and when server object raise an event then client trace that event.
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
thanks for your answer ,
if i have 100's of users on my server...would it be a " wise way " to costantly send an updated list to all of my 100's of users for any small event such as this ?
or is there any more efficient way to this?
-- modified at 1:51 Monday 1st October, 2007
Net
|
|
|
|
|
So you are not able to creat a client listner event for server ?
It's easy way you can creat a client listner and handle in it with parameter.
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
Parwej Ahamad wrote: So you are not able to creat a client listner event for server ?
Parwej,
As per my knowledge, we wont be able to fire events on client/server using TCP communication. Because messages will be passed through streams. So how events are fired ? Or am I missing something ?
|
|
|
|
|
udikantz wrote: can anyone advice me of a common method which i could retreive with my client program an updated list of users online on my server ,
How you are communicating with the client to server ? Are you keeping client socket object on server ? if yes you can create a method on server which returns the total count of this objects. Client has to send message to the server requesting for this number (may be you could define some proprietary protocols). Catch the message on server and call the appropriate method, and sends the message back to client.
|
|
|
|
|
i am communicating with client server over a tcp socket as for now i am using strings to communicate.... , i am keeping client socket object for each client on the server side , i need to send some sort of updated list or dataset to all of my clients which includes information such the username and some other stuff.... , the question is how can i send that kind of list , there must be some efficient technique for that cause almost evry server have this functionality , hope i was more clear.
thanks again!
Net
|
|
|
|