5. Januar 2012 12:17
OBJECT Codeunit 50000 SearchDirectory
{
OBJECT-PROPERTIES
{
Date=02.01.12;
Time=12:00:00;
Modified=No;
Version List=iPeon 1.00;
}
PROPERTIES
{
OnRun=BEGIN
MyPath := 'C:\tmp\';
DotNetDirectoryInfo := DotNetDirectoryInfo.DirectoryInfo(MyPath);
IF NOT DotNetDirectoryInfo.Exists THEN
ERROR(Text000, CONVERTSTR(MyPath, '\', '/'));
DotNetArray := DotNetDirectoryInfo.GetFiles('*.txt');
IF DotNetArray.Length > 0 THEN
FOR i := 0 TO DotNetArray.Length - 1 DO BEGIN
DotNetFileInfo := DotNetArray.GetValue(i);
MyFile.TEXTMODE(TRUE);
MyFile.WRITEMODE(FALSE);
MyFile.OPEN(DotNetFileInfo.FullName());
REPEAT
MyFile.READ(FileLine);
//Do something
UNTIL MyFile.POS = MyFile.LEN;
MyFile.CLOSE;
MESSAGE(DotNetFileInfo.Name());
END;
END;
}
CODE
{
VAR
MyPath@1000000000 : Text[1024];
MyFile@1000000002 : File;
FileLine@1000000007 : Text[1024];
i@1000000013 : Integer;
DotNetDirectoryInfo@1000000019 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.DirectoryInfo";
DotNetFileInfo@1000000020 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.FileInfo";
DotNetArray@1000000022 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Array";
Text000@1000000023 : TextConst 'DEU=Importordner %1 konnte nicht gefunden oder zugegriffen werden.;ENU=Importdirectory %1 couldn''t be find or accessed.';
BEGIN
END.
}
}