本文介绍了FTP ListDirectoryDe​​tails不会一致地返回数据/时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用ListDirectoryDe​​tails时,它有时会返回带有月份和日期或月份和年份的字符串。 

我正在将此呼叫用于FTP服务器上有15个文件的一个目录。 大约有一半人以这种或那种方式回来。 它是一致的但我最终必须在每个文件上使用GetDateTimeStamp来检索每个文件的完整日期和时间。 

如何使ListDirectoryDe​​tails始终返回完整的日期和时间 - 包括年份。

我现在得到的例子:
-rw-r --r-- 1 ftp ftp        5592560 2月26日18:53 DamonJenkinsA_84_C_CTS.dds
-rw-r - r-- 1 ftp ftp        1398256 2月12日19:44 GaryMadewA_63_C_CTS.dds
-rw-r - r-- 1 ftp ftp         699192 Feb 02  2010 JeffCodyA_26_C_CTS.dds
-rw-r - r-- 1 ftp ftp          90112 Feb 02  2010 JoeExlineA_39_C_CTS.dds
-rw-r - r-- 1 ftp ftp         699192 Feb 02  2010 JoeExlineB_39_C_CTS.dds
-rw-r - r-- 1 ftp ftp             02年2月58日  2010 JoeExlineB_39_C_CTS.txt
-rw-r - r-- 1 ftp ftp        1398256 2月12日11:22 JoeSzotA_33_C_CTS.dds
-rw-r - r-- 1 ftp ftp         699192 Feb 02  2010 JohnKennedyA_71_C_CTS.dds
-rw-r - r-- 1 ftp ftp             02年2月58日  2010 JohnKennedyA_71_C_CTS.txt
-rw-r - r-- 1 ftp ftp        2796344 Feb 08 16:00 MikeHebbA_32_C_CTS.dds
-rw-r - r-- 1 ftp ftp             63 Feb 08 16:00 MikeHebbA_32_C_CTS.txt
-rw-r - r-- 1 ftp ftp         699192 Feb 17 19:11 MikeKoonA_45_C_CTS.dds
-rw-r - r-- 1 ftp ftp             26 Feb 17 19:11 MikeKoonA_45_C_CTS.txt
drwxr-xr-x 1 ftp ftp              0 Feb 26 18:53 misc
-rw -r -r-- 1 ftp ftp        2796344 2月22日10:59 RayMossA_24_C_CTS.dds

代码:

request =(

When I use ListDirectoryDetails it sometimes returns the string with the Month and Date or Month and Year. 

I'm am using this call for one directory on an FTP server with 15 files.  Roughly half of them come back one way or the other.  It's consistent but I end up having to use GetDateTimeStamp on each file to retrieve the full date and time on each file. 

How can I make ListDirectoryDetails always return the full date and time - including the year.

Example of what I'm getting now:
-rw-r--r-- 1 ftp ftp        5592560 Feb 26 18:53 DamonJenkinsA_84_C_CTS.dds
-rw-r--r-- 1 ftp ftp        1398256 Feb 12 19:44 GaryMadewA_63_C_CTS.dds
-rw-r--r-- 1 ftp ftp         699192 Feb 02  2010 JeffCodyA_26_C_CTS.dds
-rw-r--r-- 1 ftp ftp          90112 Feb 02  2010 JoeExlineA_39_C_CTS.dds
-rw-r--r-- 1 ftp ftp         699192 Feb 02  2010 JoeExlineB_39_C_CTS.dds
-rw-r--r-- 1 ftp ftp             58 Feb 02  2010 JoeExlineB_39_C_CTS.txt
-rw-r--r-- 1 ftp ftp        1398256 Feb 12 11:22 JoeSzotA_33_C_CTS.dds
-rw-r--r-- 1 ftp ftp         699192 Feb 02  2010 JohnKennedyA_71_C_CTS.dds
-rw-r--r-- 1 ftp ftp             58 Feb 02  2010 JohnKennedyA_71_C_CTS.txt
-rw-r--r-- 1 ftp ftp        2796344 Feb 08 16:00 MikeHebbA_32_C_CTS.dds
-rw-r--r-- 1 ftp ftp             63 Feb 08 16:00 MikeHebbA_32_C_CTS.txt
-rw-r--r-- 1 ftp ftp         699192 Feb 17 19:11 MikeKoonA_45_C_CTS.dds
-rw-r--r-- 1 ftp ftp             60 Feb 17 19:11 MikeKoonA_45_C_CTS.txt
drwxr-xr-x 1 ftp ftp              0 Feb 26 18:53 misc
-rw-r--r-- 1 ftp ftp        2796344 Feb 22 10:59 RayMossA_24_C_CTS.dds

Code:

request = (

FtpWebRequest WebRequest 。创建(FTPServer + " /" + FTPDir +文件夹);

request.Credentials =

FtpWebRequest)WebRequest.Create(FTPServer + "/" + FTPDir + folder);

request.Credentials =

new NetworkCredential (FTPUserID,FTPPwd);

request.Method =

new NetworkCredential(FTPUserID, FTPPwd);

request.Method =

WebRequestMethods Ftp 。ListDirectoryDe​​tails;

response =(

WebRequestMethods.Ftp.ListDirectoryDetails;

response = (

FtpWebResponse )request.GetResponse();

 

FtpWebResponse)request.GetResponse();

StreamReader reader = new StreamReader (response.GetResponseStream());

 

StreamReader reader = new StreamReader(response.GetResponseStream());

字符串 t;

t = reader.ReadToEnd();

String t;

t=reader.ReadToEnd();

推荐答案


这篇关于FTP ListDirectoryDe​​tails不会一致地返回数据/时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:03
查看更多