Hidden-Coder -1 Newbie Poster

That's got nothing to do with my topic.

Hidden-Coder -1 Newbie Poster

G'day all,

Its been a while since i've posted here - my question today is about getting the bandwidth (specifically when its accessing the internet) of a machine that is connected to my LAN. I know this can be easily achieved if I had client side software, however this isn't an option.

Also, the router that they are connected to doesn't have logging or SMP/Communities (like a Cisco router for instance) therefore I won't be able to get this information from the router.

Any insight on the theory of this would be fantastic, but practical knowledge would be great as well.

Thanks all,

HC

Hidden-Coder -1 Newbie Poster

Thank guys for all your replies. I'll check it out and see if I can get it to work. I'll keep you updated.

Hidden-Coder -1 Newbie Poster

G'day all,

I'm currently a little stuck with my application. The strings i'm working with are a filepath and then a filename, what I want is to compare the filename with the filepath and then output the directory that most matches with the filename. My current code below works like the following:

Filepath: C:\Program Files\ABCDE Folder\system
Filename: ABCDE.exe
Return: ABCDE Folder

However it wouldn't work if the first few characters don't match, for example:

Filepath: C:\Program Files\ABCDE Folder\system
Filename: ACDE.exe or AAABBBCCDDEE.exe
Return: null

What i'm aiming for is to find out a way to get some sort of percentage of "accuracy" of the filename to any given directory within the filepath. Thanks again for any input. :D

public string FindProgramName(string FullPath)
        {
            string filename;
            string PathuntilFile;

            filename = Path.GetFileNameWithoutExtension(FullPath);
            PathuntilFile = Path.GetDirectoryName(FullPath);

            filename = filename.ToLower();
			string[] pathComponents = PathuntilFile.ToLower().Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
			foreach (string comp in pathComponents)
			{
				int matches = 0;
				for (int i = 0;  i < comp.Length && i < filename.Length; i++)
				{
					if (comp[i] == filename[i])
					{
						if (++matches == 3)
							return comp;
					}
					else
					{
						break;
					}
				}
			}
			return "";
		}
Hidden-Coder -1 Newbie Poster

There are many ways you could go about that. I don't have any algorithm, but one way, Get the speed, go through the other speeds and for each speed its faster than +1 to the priority. Hopefully the example below explains what i'm getting at. So the highest priority goes first.

Player Speed 1: 17 - Faster than 4 others
Player Speed 2: 13 - Faster than 2 others
Player Speed 3: 12 - Faster than 0 others

Enemy Speed 1: 14 - Faster than 3 others
Enemy Speed 2: 12 - Faster than 0 others
Enemy Speed 3: 18 - Faster than 5 others

Hidden-Coder -1 Newbie Poster

That is scary.. lol.

Hidden-Coder -1 Newbie Poster

Because you want the iterations to continue on failure and the method you're calling is an all-or-nothing approach. If you want something in between you need to roll your own solution.

Have you had any progress with your application?

Oh ok, well that actually makes sense. I've implimented the code you provided and it works really well. Going over it, I can't fully grasp what its doing but thats ok, I have time to figure it out. I have another question, but i'll put it in another post - its to do with String parsing. The progress on my app is like a snow ball really. Very slow at the moment, but its getting faster :D.

Hidden-Coder -1 Newbie Poster

Thanks for the reply mate. I don't really know why it wouldn't be good enough to do what I want. Could you perhaps explain it for me?. I'll go over your code as well, thanks for that!

Hidden-Coder -1 Newbie Poster

G'day all,

When i'm using the search function (Below) I get a Unauthorized Access Exception on certain folders, which isn't a problem, however after this Exception i'm not getting any results. I have tried searching around but I couldn't make sense of alot of stuff that I found. I haven't much experience in exception handling so any insight would be good. I've tried throwing the exeption and using "continue" but I don't really understand how to do that. Thanks!

try
            {
                // Loop through each ticked drive
                foreach (string chkDrive in CkBox_Drives.CheckedItems)
                {
                        foreach (string files in Directory.GetFiles(chkDrive, "*.exe", SearchOption.AllDirectories))
                        {
                            CkBox_Found.Items.Add(files);
                        }
                }
            }
          catch (System.UnauthorizedAccessException excpt)
            {
               LBox_Errors.Items.Add((excpt.Message));
           }
Hidden-Coder -1 Newbie Poster

>how i'm going to keep going deeper into a directory and still manage to search other folders.
Use,

System.IO.Directory.GetDirectories("path", "pattern", System.IO.SearchOption.AllDirectories);

Thanks for the quick reply!, and it helped! :D

Hidden-Coder -1 Newbie Poster

G'day all,

The program i'm currently working on has a search feature, I want to be able to search a Folder and any Sub-Folders contained within that structure. I'm really confused at the moment as to how i'm going to keep going deeper into a directory and still manage to search other folders also, I was doing some pretty funky stuff with the GetDirectories method - mostly because i'm new to C#.. :S. I appreciate any help you can provide.

Here is my current code:

try
            {
                // Loop through each ticked drive
                foreach (string chkDrive in CkBox_Drives.CheckedItems)
                {
                    // Search for directories in current directory 
                    for (string[] directories = Directory.GetDirectories(chkDrive); directories.Count().Equals(0); directories.Count().DoesNotEqual(0))
                    {
                        foreach (string files in Directory.GetFiles(chkDrive, "*.exe"))
                        {
                            CkBox_Found.Items.Add(files);
                        }
                    }
                }
            }
            catch (System.Exception excpt)
            {
                MessageBox.Show(excpt.Message);
            }
Hidden-Coder -1 Newbie Poster

Thanks for the theories. It looks like that the term Peer-to-Peer is far too broad of a concept to be summarized in one paragraph - despite what the "meaning" may be, depending on where you go. My approaching method to this was based on a LAN only topology.

I still disagree on some points - but thats the beauty of opinions, everybody has them.

Cheers.

Hidden-Coder -1 Newbie Poster

I understand where you're coming Scott. However to me it seems that you're still using a server in that case. What happens (in your example) when NodeA goes down or disconnects? If another Node, for example NodeC, connects and is speaking to NodeB and NodeA goes down, they would no longer be able to speak to each other.

Lets us know what you think.

Matt.

Hidden-Coder -1 Newbie Poster

It may be worth your while using Google to find out how P2P networks work and also look into how TCP and UDP protocols work.

Hidden-Coder -1 Newbie Poster

None of these are actually Peer-to-Peer. P2P Chat would be connectionless, therefore its is not a client/server model. True P2P Chat would be an application on a host PC that would broadcast itself on a unique port and not caring which other host PC receives and processes the information, doing the same for messages it sends - Hence, Connectionless. This would require use of the UDP Routed protocol.

Just my 2 cents.

sknake commented: I disagree -1
tomato.pgn commented: right +0