在DELPHI程序中怎么获取FTP服务器上文件的修改时间?用 NMFTP 控件会获取到如下情况的结果:
修改时间为2003年以前的文件
. 可以获取到文件修改时间的年月日,不能获取到时分秒
修改时间为2003年及2003年以后的文件
. 可以获取到文件修改时间的月日时分,不能获取到年、秒。
修改时间为2003年以前的文件
. 可以获取到文件修改时间的年月日,不能获取到时分秒
修改时间为2003年及2003年以后的文件
. 可以获取到文件修改时间的月日时分,不能获取到年、秒。
解决方案 »
- Delphi7 的VCL代码是不是出错了??大家一起分析一下
- 怎么在 dbgrid 中取出某一列的最大值, 不能用SQL语句来做
- 请问怎样得到一个控件最顶层的Parent(就是TForm)?
- 求助:关于FORMULA ONE或三层结构BLOB字段的更新问题
- 如何做出象delphi一样的窗体,主窗体可以打开、关闭其它窗体,但其它窗体不受主窗体位置的影响
- 参与者有分,快快领取!
- delphi5和delphi7能否共存?
- 请问在哪里可下载进销存的源程序?
- WebConnection的问题,欢迎讨论!!!
- 康炜的自由空间为什么所有的页面都进不去?如何打开他的vcl控件页?
- 请教DELPHI老手!!!关于子父窗体?
- 启动窗体在屏幕中央?
begin
NMFTP1.Vendor := NMOS_AUTO;
NMFTP1.Host := '192.0.0.1';
NMFTP1.UserID := 'xxx';
NMFTP1.Password := 'xxx';
NMFTP1.Connect;
NMFTP1.ParseList := True;
NMFTP1.Passive := True;
NMFTP1.List;
Sleep(2000);
NMFTP1.Disconnect;
end;procedure TForm1.NMFTP1ListItem(Listing: String);
begin
Memo1.Lines.Add(Listing);
end;Memo1中就保存了文件名和修改时间以及文件的大小!!!
修改时间为2003年以前的文件
. 可以获取到文件修改时间的年月日,不能获取到时分秒
修改时间为2003年及2003年以后的文件
. 可以获取到文件修改时间的月日时分,不能获取到年、秒。
var
i, j : Integer;
begin
i := 1;
j := length(AString);
result := True;
while i <= j do begin
if not IsNumeric(AString[i]) then begin
result := False;
break;
end;
Inc(i);
end;
end;procedure TForm1.Calc;
begin
InChange := True; lblYear.Caption := IntToStr(IdDateTimeStamp1.Year);
txtYear.Text := lblYear.Caption;
// Hack due to limitation of TUpDown
udYear.Position := IdDateTimeStamp1.Year div 5;
if IdDateTimeStamp1.IsLeapYear then begin
lblIsLeapYear.Caption := 'Yes';
end else begin
lblIsLeapYear.Caption := 'No';
end; lblDay.Caption := IntToStr(IdDateTimeStamp1.Day);
txtDay.Text := lblDay.Caption;
udDay.Position := IdDateTimeStamp1.Day;
lblDayOfMonth.Caption := IntToStr(IdDateTimeStamp1.DayOfMonth);
lblDayOfWeek.Caption := IntToStr(IdDateTimeStamp1.DayOfWeek);
lblDayOfWeekName.Caption := IdDateTimeStamp1.DayOfWeekName + ' / '
+ IdDateTimeStamp1.DayOfWeekShortName; lblWeekNo.Caption := IntToStr(IdDateTimeStamp1.WeekOfYear);
udWeek.Position := IdDateTimeStamp1.WeekOfYear + 1; lblMonthNo.Caption := IntToStr(IdDateTimeStamp1.MonthOfYear);
udMonth.Position := IdDateTimeStamp1.MonthOfYear + 1;
lblMonthName.Caption := IdDateTimeStamp1.MonthName + ' / '
+ IdDateTimeStamp1.MonthShortName; lblSeconds.Caption := IntToStr(IdDateTimeStamp1.Second);
txtSecond.Text := lblSeconds.Caption;
// Hack due to limitations of TUpDown control
udSecond.Position := (IdDateTimeStamp1.Second div 3) + 1; lblBeatOfDay.Caption := IntToStr(IdDateTimeStamp1.BeatOfDay); lblMinuteOfDay.Caption := IntToStr(IdDateTimeStamp1.MinuteOfDay);
udMinuteOfDay.Position := IdDateTimeStamp1.MinuteOfDay + 1;
lblHourOf12Day.Caption := IntToStr(IdDateTimeStamp1.HourOf12Day);
udHourOf12Day.Position := IdDateTimeStamp1.HourOf12Day + 2;
if IdDateTimeStamp1.IsMorning then begin
lblHourOf12Day.Caption := lblHourOf12Day.Caption + ' (am)';
end else begin
lblHourOf12Day.Caption := lblHourOf12Day.Caption + ' (pm)';
end;
lblHourOf24Day.Caption := IntToStr(IdDateTimeStamp1.HourOf24Day);
lblMinuteOfHour.Caption := IntToStr(IdDateTimeStamp1.MinuteOfHour); lblMilliseconds.Caption := IntToStr(IdDateTimeStamp1.Millisecond);
udMillisecond.Position := IdDateTimeStamp1.Millisecond + 1; lblAsRFC822.Caption := IdDateTimeStamp1.GetAsRFC822; lblAsISO8601Calender.Caption := IDDateTimeStamp1.GetAsISO8601Calendar;
lblAsISO8601Ordinal.Caption := IDDateTimeStamp1.GetAsISO8601Ordinal;
lblAsISO8601Week.Caption := IDDateTimeStamp1.GetAsISO8601Week; InChange := False;
end;
begin
If not IsNumericString(txtYear.Text) then begin
exit;
end; if not IsNumericString(txtDay.Text) then begin
exit;
end; Calc;
end;procedure TForm1.txtYearExit(Sender: TObject);
begin
if InChange then exit; InChange := True;
if IsNumericString(txtYear.Text) then begin
IdDateTimeStamp1.SetYear(StrToInt(txtYear.Text));
Calc;
end;
InChange := False;
end;procedure TForm1.txtDayExit(Sender: TObject);
begin
if InChange then exit; InChange := True;
if IsNumericString(txtDay.Text) then begin
IdDateTimeStamp1.SetDay(StrToInt(txtDay.Text));
Calc;
end;
InChange := False;
end;procedure TForm1.txtDayChange(Sender: TObject);
begin
if InChange then exit; txtDay.Text := Copy(txtDay.Text, 1, 5);
InChange := True;
if (IsNumericString(txtDay.Text)) and (txtDay.Text <> '') then begin
IdDateTimeStamp1.SetDay(StrToInt(txtDay.Text));
Calc;
end;
InChange := False;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
InChange := False;
FirstTime := True;
udSecond.Max := SmallInt(IdDateTimeStamp.IdSecondsInDay);
Calc;
end;procedure TForm1.txtYearChange(Sender: TObject);
begin
if InChange then exit; // Quick hack to prevent Integer overflow
txtYear.Text := Copy(txtYear.Text, 1, 5); InChange := True;
if (IsNumericString(txtYear.Text)) and (txtYear.Text <> '') then begin
IdDateTimeStamp1.SetYear(StrToInt(txtYear.Text));
Calc;
end;
InChange := False;
end;procedure TForm1.txtSecondChange(Sender: TObject);
begin
if InChange then exit; txtSecond.Text := Copy(txtSecond.Text, 1, 5);
InChange := True;
if (IsNumericString(txtSecond.Text)) and (txtSecond.Text <> '') then begin
IdDateTimeStamp1.SetSecond(StrToInt(txtSecond.Text));
Calc;
end;
InChange := False;
end;procedure TForm1.txtSecondExit(Sender: TObject);
begin
if InChange then exit; InChange := True;
if IsNumericString(txtSecond.Text) then begin
udSecond.Position := StrToInt(txtSecond.Text);
end else begin
txtSecond.Text := IntToStr(udSecond.Position);
end;
Calc;
InChange := False;
end;procedure TForm1.FormActivate(Sender: TObject);
begin
if FirstTime then begin
FirstTime := False;
IdDateTimeStamp1.SetFromTDateTime(Now);
Calc;
end;
end;procedure TForm1.cmdNowClick(Sender: TObject);
begin
IdDateTimeStamp1.SetFromTDateTime(Now);
Calc;
end;procedure TForm1.cmdResetClick(Sender: TObject);
begin
IdDateTimeStamp1.SetYear(1);
IdDateTimeStamp1.SetDay(1);
IdDateTimeStamp1.SetSecond(1);
IdDateTimeStamp1.SetMillisecond(1);
Calc;
end;procedure TForm1.udYearClick(Sender: TObject; Button: TUDBtnType);
begin
if InChange then exit; InChange := True;
if Button = btNext then begin {Up}
IdDateTimeStamp1.AddYears(1);
end else if Button = btPrev then begin {Down}
IdDateTimeStamp1.SubtractYears(1);
end;
Calc;
InChange := False;
end;procedure TForm1.udDayClick(Sender: TObject; Button: TUDBtnType);
begin
if InChange then exit; InChange := True; if Button = btNext then begin {Up}
IdDateTimeStamp1.AddDays(1);
end else if Button = btPrev then begin {Down}
IdDateTimeStamp1.SubtractDays(1);
end;
Calc;
InChange := False;
end;procedure TForm1.udSecondClick(Sender: TObject; Button: TUDBtnType);
begin
if InChange then exit; InChange := True; if Button = btNext then begin
IdDateTimeStamp1.AddSeconds(1); {Up}
end else if Button = btPrev then begin
IdDateTimeStamp1.SubtractSeconds(1); {Down}
end;
Calc;
InChange := False;
end;procedure TForm1.udWeekClick(Sender: TObject; Button: TUDBtnType);
begin
if InChange then exit; InChange := True; if Button = btNext then begin {Up}
IdDateTimeStamp1.AddWeeks(1);
end else if Button = btPrev then begin {Down}
IdDateTimeStamp1.SubtractWeeks(1);
end;
Calc;
InChange := False;
end;procedure TForm1.udMonthClick(Sender: TObject; Button: TUDBtnType);
begin
if InChange then exit; InChange := True; if Button = btNext then begin {Up}
IdDateTimeStamp1.AddMonths(1);
end else if Button = btPrev then begin {Down}
IdDateTimeStamp1.SubtractMonths(1);
end;
Calc;
InChange := False;
end;procedure TForm1.udMinuteOfDayClick(Sender: TObject; Button: TUDBtnType);
begin
if InChange then exit; InChange := True; if Button = btNext then begin {Up}
IdDateTimeStamp1.AddMinutes(1);
end else if Button = btPrev then begin {Down}
IdDateTimeStamp1.SubtractMinutes(1);
end;
Calc;
InChange := False;
end;procedure TForm1.udHourOf12DayClick(Sender: TObject; Button: TUDBtnType);
begin
if InChange then exit; InChange := True; if Button = btNext then begin {Up}
IdDateTimeStamp1.AddHours(1);
end else if Button = btPrev then begin {Down}
IdDateTimeStamp1.SubtractHours(1);
end;
Calc;
InChange := False;
end;procedure TForm1.udMillisecondClick(Sender: TObject; Button: TUDBtnType);
begin
if InChange then exit; InChange := True; if Button = btNext then begin {Up}
IdDateTimeStamp1.AddMilliseconds(1);
end else begin {Down}
IdDateTimeStamp1.SubtractMilliseconds(1);
end;
Calc;
InChange := False;
end;end.
begin
Memo1.Lines.Add(Listing);
end;
http://fengyebar.cn.st
http://soft.winzheng.com/SoftDown.asp?ID=20734