I'm trying to send rows of string to a remote SFTP server.
I'm using SftpClient With Renci.SSHNet.
This is how I build my rows of string:
row = string.Format("{0},{1},{2},{3:dd/MM/yyyy HH:mm:ss},{4:dd/MM/yyyy HH:mm:ss},{5:dd/MM/yyyy HH:mm:ss},{6},{7},{8},{9},{10},{11}", queue_id, queue_name, taskId,
customRow.createdTime.AddSeconds(secondsAdd), first_handled_date_and_time.AddSeconds(secondsAdd), customRow.closedTime.AddSeconds(secondsAdd),
task_work_time_in_s, after_task_work_time_in_s, queuing_time_in_s, is_handled_within_service_level, task_status_description, handling_time);
This is my code to upload the rows:
using (SftpClient sftp = new SftpClient(con))
{
try
{
if (sftp.IsConnected)
sftp.Disconnect();
sftp.OperationTimeout = TimeSpan.FromTicks((TimeSpan.TicksPerMinute * 5));
sftp.Connect();
sftp.WriteAllLines(filePath, content, encoding);
}
.
.
.
}
The field content is an array of row from the previous code part.
My main problem is that the date format in the file that arrives is dd/MM/yyyy for the first column and MM-dd-yyyy in the other 2 date columns.
Can someone please explain it to me or tell me what am I doing wrong?
Thank you in advance
Possibly the date deserializer is defaulting to the U.S. format of month/day/year with some edge case handling for when you write it backwards (And it can tell, i.e. when the month is 13-31).
06/08/2006 - Means 06-Aug-2006 to you but 08-Jun-2006 to the deserializer. Maybe it can figure out that 06/21/2006 means 21-Jun-2006 because 21 couldn't have been the month.
Try formatting with 3 M's to avoid confusion. dd/MMM/yyyy