|
Swetha Srinivasan wrote: i want to check if the file is already open or not
Do you know which process opened the file?
Have u got error when you open the file first time from your code?
Have u handled the stream properly?
I think its opened by CLR itself.isn't it?
|
|
|
|
|
I have solved the problem.I put the code in Try..Catch...
|
|
|
|
|
Hi All,
If I have a form with several buttons and the click event handler for all the buttons points to the same handler, how can I determine in handler which button was clicked?
this.button1.Click += new System.EventHandler(this.button_ClickHandler);
this.button2.Click += new System.EventHandler(this.button_ClickHandler);
this.button3.Click += new System.EventHandler(this.button_ClickHandler);
private void button_ClickHandler(object sender, EventArgs e)
{
MessageBox.Show("Who raised this event?");
}
|
|
|
|
|
you have object sender.
|
|
|
|
|
OF COURSE...I'm only annoyed because I didn't figure that out for myself. -Thanks
MessageBox.Show(((Button)sender).Name + " Who raised this event?");
|
|
|
|
|
A better way to do this is:
Button b = sender as Button;
if (b != null)
{
MessageBox.Show(b.Name + " Who raised this event?");
} Just casting the sender to a Button is a bad practice as it will throw an exception if the sender is not a button.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi, I tend to use:
if (sender is Button)
{
Button button = sender as Button;
} for no particular reason. Is there any advantage to using as , then null checking over is , then as in your opinion?
|
|
|
|
|
I don't think there is any advantage either way; it's a stylistic thing. I just like my null checks to be explicit and visible!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi,
i need to send a user request form to approver in c# application.i am sending it as a form in body it is working fine in outlook 2003, but in outlook 2007 its not working because microsoft changes html contol in outlook mail. is there any procedure to send this form as an image attchment to user.
thanks in advance.
|
|
|
|
|
Dear All,
I have developed a winform app which runs at startup. i have done this using registry key.
the question which bothers me is, does this application runs prior logging to my computer?
what I want is that when the logon screan appears this application should run at background whether i login or not.
any ideas or suggestions?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
I believe you need a windows service.
|
|
|
|
|
Abdul Rahman Hamidy wrote: does this application runs prior logging to my computer?
No.
Abdul Rahman Hamidy wrote: what I want is that when the logon screan appears this application should run at background whether i login or not.
any ideas or suggestions?
I'm not sure this is possible. I don't think anything runs prior to login, except the gina.dll that handles login.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: I don't think anything runs prior to login, except the gina.dll that handles login.
I believe windows services does.
|
|
|
|
|
If we cant run winform in bg before logging, any suggestions how to run application only once, as
if every user logs in, the application should not run for each user.
the first user which logs in, the application should run and if other users logs in then that application should not for other users.
i have also concern with remote connection, as our server is always running and one user is always logged in, if others want to log in using remote connection or any other resources the application should not run for each user.
any idea or suggestions.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Hello,
I have created a form with a windows media player video object and made buttons to use the player. What I would like to know is if there is a way to view the bytes of the file that is being played while it is being played. Basically, I have metadata stitched in the video stream and I need to search the stream as it is playing and display the data. The metadata is completely custom, that's why I need to see the byte stream.
Thanks,
Fox
|
|
|
|
|
File.ReadAllBytes will read your file. Synching to what part of the data is being viewed right now, is probably the main challenge.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I recently made a server and client in separate EXEs and I would like to run both on one PC. The server is listening on port 19357 and of course the client will connect via the same port. Of course this causes a conflict and an exception is thrown. I know it is possible to do this, I just don't know what I'm missing. For now I have a 'bandaid' on the problem by changing the port that the client connects through and forwarding the port through my router to the correct port. However I do not wish to use this as a permanent solution.
My server uses the following code to listen:
tlsClient = new TcpListener(19357);
tlsClient.Start();
My client uses the following code to connect:
tcpServer.Connect(strHost, 19357);
And of course my threaded to keep listening for incoming connections.
I can change the address in my client to 127.0.0.1 without any problems, but if I try to use my domain as the address on the PC that is running the host, I get an error about the port being in use. I know it is possible to connect in the method that I'm talking about because I am running Apache web server on this PC and I am able to connect to the server with a web browser using my domain as the address. But of course when I go check to see what ports are in use, i get some random number as the local port and 80 as the remote port. The web browser just cycles through ports on the local side until it finds one not in use while still connecting to the proper port on the remote end. How can I do this with my program?
Thanks,
Thomas
|
|
|
|
|
sirEgGhEaD wrote: Of course this causes a conflict and an exception is thrown. I know it is possible to do this, I just don't know what I'm missing.
Please entertain my ignorance, but, exactly what conflict are you referring to? If a server listens on port X, and a client connects to port X, what is the conflict?
|
|
|
|
|
After my server is running and I attempt to use my client to connect, I get an exception because the port is already in use.
|
|
|
|
|
Show the code where you create the TcpClient instance.
|
|
|
|
|
|
You did not show the code that instantiates the client. You only showed the call to the connect method.
Show the code that creates the client.
|
|
|
|
|
My server uses the following code to listen:
tlsClient = new TcpListener(19357);
tlsClient.Start()
My client uses the following code to connect:
tcpServer = new TcpClient();
tcpServer.Connect(strHost, 19357);
|
|
|
|
|
I thought you might have been mistakenly attempting to bind the client to the same port as the server was listening on.
Do you get the exception when the server is created or when you call the connect method of the client?
|
|
|
|
|
Well that is my thought as well. I run the server, and start listening with no problems, no exceptions. I run the client and attempt to connect and the exception is thrown. I haven't had this problem when writing TCPIP programs in the past. This is my first attempt at one with the .net framework. But it does seem to be attempting to bind the client on the same port that the server is listening on. I wish I knew how to change this and have the client connect to the server on the proper port, but bind a different port on the local end.
|
|
|
|