List Info

Thread: NULL Line issue with a FTP send method in managed C++




NULL Line issue with a FTP send method in managed C++
user name
2006-11-06 03:48:49
Listers,
I am writing a FTP Text file send method in managed C++.
This piece of
code sends an additional line with null (hex 00) to the
remote server.
If have 2 lines of text as below,
Ludmila Koganer
Is Ftping

the server will have three lines. the first two lines excaly
matches up
but it adds an additional line which has a hex'00' on it.
The hex 00 is
originating from the last byte on the file. (There is a
x'00' after the
letter 'g' in the two lines as above. I viewed it with hex
editor. This
happens in all text editiors.

I am not sure how to avoid this third line on the remote
server.

Here is the code.
NetworkStream^ ns = gcnew NetworkStream(*ptrdataSock, true);
 StreamWriter^ sw = gcnew StreamWriter(ns);
 String^ line;
 String^ crlf = "rn";
 int count = 0;
 try
 {
  while (sr->Peek() >= 0 )
    {
     line = sr->ReadLine();
     count = count + 1;
     if (line != NULL)
     {
      sw->Write(line);
      sw->Write(crlf);
     }
 }
 sr->Close();
 sw->Flush();
 sw->Close();
 catch(Exception^ Ex)
 ....
 ....

Thanks a bunch
Ludmil

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )