I have written FTP server in C# which is working quite fine with client on one machine, but when i try to send file to server from other PC,

Exception occurs, Input string was not in correct format

double FileSize = double.Parse(System.Text.Encoding.ASCII.GetString(downBuffer, 0, bytesSize));

Recommended Answers

All 3 Replies

That usually means that the parsing failed. Make sure that what you are trying to parse can actually be parsed into a double.

Console.WriteLine(System.Text.Encoding.ASCII.GetString(downBuffer, 0, bytesSize));

I have written FTP server in C# which is working quite fine with client on one machine, but when i try to send file to server from other PC,

Exception occurs, Input string was not in correct format

double FileSize = double.Parse(System.Text.Encoding.ASCII.GetString(downBuffer, 0, bytesSize));

Parse failed - suggested by @sergb. Can you maybe provide some more information about what it is you are trying to do? I think you are trying to get the length of file. Isn't it?

To parse string to double you can use TryParse static method.

double v;
double.TryParse(System.Text.Encoding.ASCII.GetString(downBuffer, 0, bytesSize),out v);

Now my self-written FTP server is working fine with my self written FTP client, but when i try to connect my server through CUTEFTP or COREFTP clients then i am unable to receive files. it gives some exceptions like "illegal character in path" "C:\path not found"
:(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.