Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
22.5k views
in .NET FTP by (160 points)
Hi,

i have some problems using FTPClient.DirDetails().
In some cases, calling DirDetails(path) throws following Exception:

System.FormatException: String was not recognized as a valid DateTime.
at EnterpriseDT.Net.Ftp.FTPFileFactory.Parse(String[] files)
at EnterpriseDT.Net.Ftp.FTPClient.DirDetails(String dirname)

Maybe there is a problem parsing date values with a leading zero? For example 'mar 03'

Thanks in advance

16 Answers

0 votes
by (158k points)
Hi, there are quite a few variations in directory listing formats. We are gradually covering the majority.

Can you post up a snippet of the directory listing that causes the problem and we will take a look.

Hi,

i have some problems using FTPClient.DirDetails().
In some cases, calling DirDetails(path) throws following Exception:

System.FormatException: String was not recognized as a valid DateTime.
at EnterpriseDT.Net.Ftp.FTPFileFactory.Parse(String[] files)
at EnterpriseDT.Net.Ftp.FTPClient.DirDetails(String dirname)

Maybe there is a problem parsing date values with a leading zero? For example 'mar 03'

Thanks in advance
0 votes
by
Hi, there are quite a few variations in directory listing formats. We are gradually covering the majority.
[/b]

How you do that ?
0 votes
by (158k points)
We keep files consisting of different types of listings that people send us and test against them.

Hi, there are quite a few variations in directory listing formats. We are gradually covering the majority.


How you do that ?
0 votes
by (160 points)
Hi, there are quite a few variations in directory listing formats. We are gradually covering the majority.

Can you post up a snippet of the directory listing that causes the problem and we will take a look.


Yes i can, you just have to tell me how doing that ;)
Is there a way to get the received data displayed?
0 votes
by (158k points)
Use FTP.EXE to log into the server.

Navigate to the directory in question using cd.

Type 'dir' to get the listing, and copy and paste it.

Hi, there are quite a few variations in directory listing formats. We are gradually covering the majority.

Can you post up a snippet of the directory listing that causes the problem and we will take a look.


Yes i can, you just have to tell me how doing that ;)
Is there a way to get the received data displayed?
0 votes
by
I am getting the same problem.

Is there a fix for this yet?

Here is the listing from a directory using the FTPClient.Dir Method


-r-xr-xr-x 1 owner group 1754 Dec 14 17:08 _vti_inf.html
drwxrwxrwx 1 owner group 0 Jun 12 2002 _vti_log
drwxrwxrwx 1 owner group 0 Jan 7 8:57 Admin
drwxrwxrwx 1 owner group 0 Dec 20 17:33 AnsFTP
drwxrwxrwx 1 owner group 0 May 26 2003 aspnet_client
drwxrwxrwx 1 owner group 0 Mar 21 2003 Client Files
-r-xr-xr-x 1 owner group 10887 Dec 15 8:36 Default.htm
dr-xr-xr-x 1 owner group 0 Sep 3 2003 Dss_test
drwxrwxrwx 1 owner group 0 Dec 17 10:59 eCard
drwxrwxrwx 1 owner group 0 Dec 16 22:01 eCard_2003
drwxrwxrwx 1 owner group 0 Dec 20 17:11 eReporting
drwxrwxrwx 1 owner group 0 Dec 15 8:37 Financial
dr-xr-xr-x 1 owner group 0 Sep 3 2003 IBM Audit
dr-xr-xr-x 1 owner group 0 Feb 27 17:13 images
d--------- 1 owner group 0 Mar 23 11:36 internal
dr-xr-xr-x 1 owner group 0 Dec 15 8:35 Lists
drwxrwxrwx 1 owner group 0 Nov 26 2:23 Login
-rwxrwxrwx 1 owner group 136 Nov 30 14:41 Login.htm
-rwxrwxrwx 1 owner group 379 Nov 26 2:22 LoginNew.htm
d--------- 1 owner group 0 Nov 18 11:04 Manuf
drwxrwxrwx 1 owner group 0 Apr 22 15:30 Marquee
d--------- 1 owner group 0 Sep 3 2003 Natural
dr-xr-xr-x 1 owner group 0 Nov 19 2002 NewWeb
d--------- 1 owner group 0 Jan 13 15:02 NMR
drwxrwxrwx 1 owner group 0 May 9 2003 NMR Demo
-r-xr-xr-x 1 owner group 2446 Jun 12 2002 postinfo.html
d--------- 1 owner group 0 Nov 30 16:05 Retail
dr-xr-xr-x 1 owner group 0 Nov 5 2002 RFD Revised
-r-xr-xr-x 1 owner group 139 Oct 10 2002 RFD.htm
dr-xr-xr-x 1 owner group 0 Nov 5 2002 RFD_Demo10.3
-rwxrwxrwx 1 owner group 255 Nov 26 2:20 Sample.htm
-rwxrwxrwx 1 owner group 337 May 26 8:21 SSO.htm
-rwxrwxrwx 1 owner group 379 Nov 26 2:20 SSONew.htm
d--------- 1 owner group 0 Mar 19 9:08 Synd
d--------- 1 owner group 0 Dec 6 12:49 SysOp
drwxrwxrwx 1 owner group 0 Jun 2 17:47 team folders
dr-xr-xr-x 1 owner group 0 May 31 11:18 TeamFolders
dr-xr-xr-x 1 owner group 0 Dec 20 10:19 tech
0 votes
by (158k points)
1.1.4 will be out in a few days with some DirDetails enhancements. Send us your email address (support at enterprisedt dot com) if you want to test a pre-release.

I am getting the same problem.

Is there a fix for this yet?

Here is the listing from a directory using the FTPClient.Dir Method

0 votes
by
Hi,

ich tried the new Version 1.1.4, but I have the same error:

"String was not recognized as a valid DateTime"

Here's the listing of the FTP:

drwxr-xr-x    2 0        0            4096 Oct 16 15:58 atd
drwxr-xr-x    2 0        0            4096 Oct 16 15:58 backup
drwxr-xr-x    2 752      102          4096 Oct 16 16:48 files
drwxr-xr-x    6 752      102          4096 Dec 17 22:58 html
drwxr-xr-x    3 0        0            4096 Dec 28 01:24 log
drwxrwxrwx    2 752      102          4096 Oct 16 15:58 phptmp
drwxr-xr-x    2 752      102          4096 Oct 16 15:58 restore


I use the following code:

FTPClient ftp = new FTPClient("myserver");
ftp.Login("username", "password");
FTPFile[] files = ftp.DirDetails(".");


and the last line throws the exception.

I hope that you can help me.
0 votes
by (158k points)
We will need a stack trace for this.

I've tested your listing against 1.1.4 and it seems to work fine - are you sure you have 1.1.4?
0 votes
by
Hi,
this is a problem with the culture info. You shouldn't use the CurrentCulture in the UnixFileParser, but instead the InvariantCulture:


      IFormatProvider culture = CultureInfo.InvariantCulture.DateTimeFormat;
         if (field.IndexOf((System.Char) ':') < 0)
         {
            stamp.Append(field); // year
            lastModified = DateTime.ParseExact(stamp.ToString(), format1, 
                    culture, DateTimeStyles.None);
         }
         else
         {
            // add the year ourselves as not present
                int year = CultureInfo.CurrentCulture.Calendar.GetYear(DateTime.Now);
            stamp.Append(year).Append('-').Append(field);
            lastModified = DateTime.ParseExact(stamp.ToString(), format2, 
                    culture, DateTimeStyles.None);
            
            // can't be in the future - must be the previous year
            if (lastModified > DateTime.Now)
            {
                    lastModified.AddYears(-1);
            }
         }


The same applies to the WindowsFileParser of course. Parsing of date/time formats is not culture dependend in this case. You will be able to reproduce the error, if you change the culture to DE e.g.

chz

Categories

...