krosty4782 0 Light Poster

Hey!!

I have two codes, one in c++ and the other in c# i think the problem is in the c# code, in the receive() method.

I have this:

while (!aa.Equals("filemanagerstop"))
            {                
                aa = getSocket(numsock).socketRecv();
                MessageBox.Show(aa);
            }

the socketRecv() method:

public string socketRecv()
        {
            buffer = new byte[1024]; --> I think here is the problem
                        i = socket.Receive(buffer);                 
                            recibido = System.Text.Encoding.UTF8.GetString(buffer);                            
                            return recibido;     

        }

The c++ method

hFind = FindFirstFile(path.c_str(), &FindFileData);
if(hFind != INVALID_HANDLE_VALUE)
do
       {
       if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            len = send(sock,FindFileData.cFileName,(int)strlen(FindFileData.cFileName),0);
        }
        else
        {
        }
} while(TRUE == ::FindNextFile(hFind, &FindFileData));
len = send(sock,"filemanagerstop",(int)strlen("filemanagerstop"),0);

I know that the c++ without sending the directorys/files by sockets works well, beacuse ive tried with cout.

So the problem is when the c# method shows the messages boxes, the frist shown is OK, it shows "AVG" that is my first directory.
But the second Messagebox shows ALL THE DIRECTORYS. So 2nd Messagebox: "AMD Programfiles Users etc."

I think the problem is where i writed in red color, beacuse, if i do

Bytes buffer = new byte[1024];

outside the method, in the class, the Messagebox start to show char by char, so i have thousands of Messageboxes with the chars of the directorys path.

Please help

Thanks