|
That's why I suggested that you had a routine which checked if you were connected - you don't need (or want) to connect if you are connected already!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
Hope Im not requestion to much but would you like to write that if-statemant?
|
|
|
|
|
I dunno - it's soooo difficult....
if (!clientSocket.Connected)
{
...
}
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
I changed it to
private void button1_Click(object sender, EventArgs e)
{
if (serverStream == null)
{
MessageBox.Show("Please connect to a server.");
return;
}
readData = "Conected to Chat Server ...";
msg();
clientSocket.Connect("127.0.0.1", 8888);
serverStream = clientSocket.GetStream();
byte[] outStream = System.Text.Encoding.ASCII.GetBytes(sendTextBox.Text + "$");
serverStream.Write(outStream, 0, outStream.Length);
serverStream.Flush();
Thread ctThread = new Thread(getMessage);
ctThread.Start();
}
But still the same
|
|
|
|
|
Well yes - what did you expect.
The logic I suggested is not what you did:
if (not connected)
connect
TalkToServer What you did was
if (not connected)
Complain
else
{
connect
TalkToServer
}
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
Thank you mate I appreciate your help, I changed it to this code,
the reason I commented out
because the compiler stops there when I debugg telling me that a socket is already connected, now the compiler runs withour errors but the server consoleAppplication doesn't receive any msg at all when I send it from sendTextBox..
private void button1_Click(object sender, EventArgs e)
{
if (serverStream == null)
{
MessageBox.Show("Please connect to a server.");
return;
}
else
{
readData = "Conected to Chat Server ...";
msg();
serverStream = clientSocket.GetStream();
byte[] outStream = System.Text.Encoding.ASCII.GetBytes(sendTextBox.Text + "$");
serverStream.Write(outStream, 0, outStream.Length);
serverStream.Flush();
Thread ctThread = new Thread(getMessage);
ctThread.Start();
}
}
The compiler stops on this code under the getMessage method
serverStream.Read(inStream, 0, buffSize);
|
|
|
|
|
Skytten wrote: The compiler stops on this code under the getMessage method
The compiler? What error message does it give?
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
"Failed to read data from the transport connection: An existing connection was forced to close by the remote host." It havens because I closed the Server... Anyway this project is driving me crazy man I can't see why it's not working and the Server doesn't get and show the string on the server prompt from the Client
|
|
|
|
|
I am going to write a C# 2010 application as a console application to start with. Eventually I will change the application to compile as a windows application so I do not get the dos pop windows. When this application goes into production, it will be executed by a windows scheduler. My question is the best way to pass parameters to this application.
Thus can you show me the following:
1. Code on how to accept values from parameters?
2. When the application runs as an executable, can you show me in code how to pass the values to this executable?
|
|
|
|
|
How to access command line parameters[^]. To execute a program with parameters you use a command line of the form:
program_name parameter1 parameter2 "a string parameter with spaces" parametr4 ...
|
|
|
|
|
There are several articles on here regarding parsing command line parameters. Here's one of the more recent ones:
Implementing command execution in a console application[^]
However, I caution you against expecting a Scheduled Task to be able to run a Windows application or anything that needs user interaction.
|
|
|
|
|
I would suggest that you are also likely to need a way to report on failures. So you might want to investigate that as well.
|
|
|
|
|
I see the others have you given you plenty to read regarding the parsing of parameters, so I will just add that it would be best to do ONLY the parsing of parameters and possibly writing of the help text in the Console application and put all actual program logic in a dll. That way you can plug any interface you want into your app: console window, windows UI, WPF, Web Service or whatever.
|
|
|
|
|
In a C# 2008 desktop application, I want to be able to check for a directory folder existing in a specified location. The directory path will look like C:\\main_folder\mm_yyyy. The mm_yyyy stands for the month and year.
Thus can you should be code on how to check if a folder actually exists?
|
|
|
|
|
|
I strongly recommend YYYY_MM instead.
|
|
|
|
|
I strongly agree!
To the OP: If you store file files as MM_yyyy, then the sort order is useless to you, no matter what you chose to sort by - because all the Januaries come before all the Februaries, and the years are then sorted within the month.
If you store by year first, you can retrieve the file names in "oldest first" or "newest first" without any additional processing.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
Code:
this.axFraCtrlShowPPT.Open("e:\\1.ppt",true,"PowerPoint.Show",null,null);
this.axFraCtrlShowPPT.PPTPlay();
I want to open a ppt in the axFrameControl,and play the ppt after opening it,but it encoutered an error when it was playing ppt.
Can you give me the correct answer?
modified 23-Jan-13 4:06am.
|
|
|
|
|
If you would bother to use Google for 30 seconds you could have found this:
The DSOFramer control is for demo purpose, we did not provide support for it.
NOTE: This sample is provided "AS IS" with no warranty or support from Microsoft. It is a demonstration, provided for informational purposes only, and has not been rigorously tested with all environments and ActiveX document servers. It is up to you to make it "production ready" if you use it in any development solution.
Visual C++ ActiveX Control for hosting Office documents in Visual Basic or HTML
http:
If you still have any concern, please feel free to post here.
|
|
|
|
|
Hi All, I've seen the reading of text from and writing of text to a file using C# StreamReader and StreamWriter. Also the file created is of type text. I was wondering if I can create various file types like CSS, HTML, JavaScript, etc simply by giving each file name an appropriate extension it requires. I don't have visual studio on hand so I can not test my idea. Thank you in advance for your reply.
modified 22-Jan-13 23:54pm.
|
|
|
|
|
|
You can create almost any type of file using StreamReader and StreamWriter .
|
|
|
|
|
Giving the file a valid extension will create that file. But the real question would be contents of the file. If you put valid html in a .html file than it is all fine but the moment you go ahead and start creating .exe files you will have to think how valid it is since you can not put a valid binary data in it.
So the answer to your question is yes but be careful about the file type you create.
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore, Dream. Discover.
|
|
|
|
|
You can use a StreamWriter to create any type of file - you are not limited to text:
using (StreamWriter writer = new StreamWriter(@"D:\Temp\MyFile.html"))
{
writer.Write(textToAdd);
} Will work fine, and will create a file with the HTML extension. However, that doesn't mean that the file will be readable by a web browser if you double click it - it depends on the content. Similarly, if you use a file name with a .DLL extension, it will be created, but it won;t work if you try to add it as a reference unless you write suitable content into it, or .AVI but it won't show a movie.
The extension just controls which application(s) will try to open the file - the content must also be correct and applicable to the application. You can open a .DLL file in VLC Media player provided the content is a video file and not an executable program!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
In a C# 2010 desktop application, I need to add an audit table to an application that would be similar to the 'main' table. Basically whenever anyting is changed in the 'main' table I need to show the corresponding change in the 'audit' table. The 'audit' table will be a mirror copy of the 'main' table. The only difference is one table is called 'main' table and the other table is called the 'audit' table.
**Note these table reside in a sql server 2008 r2 database.
Would you setup a trigger? If so, can you show me the sql you would use?
Would you write C#.net 2010 code? If so, can you show me the code that would solve my problem?
|
|
|
|