|
WuJunyin wrote: if you want to use string[], you should declare its length
greater than the line count of the file.
file length varies, how do I get the length of a file in lines, not chars?
|
|
|
|
|
then use List<string> if you are use .NET Framework 2.0 or above.
use ArrayList if you are use .NET Framework 1.1
its length add dynamicly. you can use it and no warry on its length.
or you should read more informance from msdn.
Glad to discuss with you and best wishes.
|
|
|
|
|
|
you are welcome.
Glad to discuss with you and best wishes.
|
|
|
|
|
Hi,
File.ReadAllLines() does it all for you.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi
Lets think that there is a client and a server. Client wants to send three files with small sizes to the server. Server's ip address and port is static.
- Server starts listening the port and accepts all the connection attempts coming from any ip address.
- Client establishes a connection to the server. After connecting, starts to send the files.
- Server recieves the files and saves them to the hard disk.
- Client disconnects.
- Server keeps listening the port and accepts all the connection attempts coming from any ip address.
Essentially, this is what I am trying to do. I am not a starter in C# but I am not advanced too. I have designed the code but only first file out of three is recieved by server without a problem. Because client or server doesn't wait for transfer to be completed.
At the same time there can be more than one client connected to server, server should be able to recieve all the files.
Thanks in advance.
|
|
|
|
|
It's called FTP. Learn it. Live it.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I know I can use FTP. But I should not use FTP because it is not secure. When you listen the network traffic with a sniffer you can easily see the username and password.
This software will be used by people and I don't want people to see the FTP login informations.
|
|
|
|
|
Can Selçik wrote: I know I can use FTP. But I should not use FTP because it is not secure. When you listen the network traffic with a sniffer you can easily see the username and password.
Really?? Google results for "Secure FTP[^]"...
|
|
|
|
|
I think you are talking about FTPS.
How can I use FTPS client in C# and is there a FTPS server for linux?
Thanks.
|
|
|
|
|
I think you're referring to SFTP[^], not FTPS.
|
|
|
|
|
Actually I am referring to FTPS not SFTP. Because SFTP is doing his job over SSH and I don't want to risk console access. I prefer using FTPS. FTPS is doing his job with using SSL for encryption.
|
|
|
|
|
Can Selçik wrote: How can I use FTPS client in C#
You can buy a library, or write the code yourself.
Can Selçik wrote: is there a FTPS server for linux?
Man, you're full of good questions today, aren't you?
I'm sure that if you took the time to use GOOGLE, you would find your answer.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
When I open a page in the WebBrowser I see appear notice board:Security information
I want programmed to automatically remove this notice I do? I'm using language C #.NET
|
|
|
|
|
From inside a web page? You can't and for good reasons. For that purpose you would have to write your own (unsecure) browser.
|
|
|
|
|
Yes, I want to design a program WebBrowser.Toi will have a program like the user to browse the Web, the program will automatically answer the panel notification Security Information usually appears in a page.
|
|
|
|
|
trinm1987 wrote: Yes, I want to design a program WebBrowser
That's a HUGE undertaking for a single person. It normally takes entire TEAMS of people a few years to write a browser from scratch. Good luck with that...
|
|
|
|
|
public class StatusChangedEventArgs : EventArgs
{
private string EventMsg;
public string EventMessage
{
get
{
return EventMsg;
}
set
{
EventMsg = value;
}
}
public StatusChangedEventArgs(string strEventMsg)
{
EventMsg = strEventMsg;
}
}
public delegate void StatusChangedEventHandler(object sender, StatusChangedEventArgs e);
public static event StatusChangedEventHandler StatusChanged;
Okay, so in the above code, we created a delegate and a custom event.
public static void OnStatusChanged(StatusChangedEventArgs e)
{
StatusChangedEventHandler statusHandler = StatusChanged;
if (statusHandler != null)
{
statusHandler(null, e);
}
}
What does the bold line do? Why do we check for null?
EDIT: The code is from C# Chat: Part 2 - Building the Chat Server (C# Programming Tutorial) • Geekpedia[^] check that out, if the above code doesn't provides what I mean.
|
|
|
|
|
Hi,
you make a local copy of StatusChanged, so the same value gets used both in the null-text and the invocation; StatusChanged is public, so it could be changed by another thread at any point in time; removing the last handler from it right after the null-test got executed would cause an exception in statusHandler(null, e);
In summary, without it your code would not be thread-safe.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 12:01 PM
|
|
|
|
|
so the same value gets used both in the null-text and the invocation;
I'm sorry, but I didn't got it, what do you mean by null-text and the invocation?
I'm converting this code to C++/CLI so I don't know C#, that's why having little problems...
|
|
|
|
|
if (statusHandler != null) <--- that looks like a null-test
statusHandler(null, e); <--- according to the comment this is an invocation
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 12:02 PM
|
|
|
|
|
Hmmm, you wrote null-text
lol.. Thanks anyways
|
|
|
|
|
Isn't that just making a copy of the reference?
And therefore no safer than testing/invoking directly on the original reference?
Subvert The Dominant Paradigm
-- bumper sticker, circa 1971
|
|
|
|
|
Yes, it copies a reference, making sure the event and the delegates inside it can not be garbage collected (it is a local copy). There still is a possibility that the event gets changed (it is kind of a linked list), to cope with that you could (probably should) add a try-catch around the invocation.
This is one of those rare cases where an empty catch block would be fine: after all, if another thread is allowed to remove the last delegate, that really means there is no need to call it anymore.
Have a look at the fine article Giorgi provided.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 12:02 PM
|
|
|
|
|
ahhh... reference to empty versus null reference. Got it.
Now I have to rework a whole bunch of code... I foresee a generic solution
Subvert The Dominant Paradigm
-- bumper sticker, circa 1971
|
|
|
|