หา Path File ที่ต้องการใช้ Delphi ทำไงครับ
??? ไม่ทราบว่า Delphi สามารถ หา path File ที่ต้องการทำได้ยังไงครับ System.IO คืออะไรครับ
มี code
program Project1;
{$APPTYPE CONSOLE}
uses
System.IO;
var
DirInfo : System.IO.DirectoryInfo;
Path : String;
Files : Array of FileInfo;
i : Integer;
begin
// Get the current folder
Path := System.IO.Directory.GetCurrentDirectory;
Console.WriteLine('Files in : ' + Path + ' :');
Console.WriteLine;
// Create our directory info object
DirInfo := System.IO.DirectoryInfo.Create(Path);
// Get the files in this folder
Files := DirInfo.GetFiles;
// Display the files - just the file names that is
for i := 0 to Length(Files)-1 do
Console.WriteLine(Files[i].Name);
Console.Readline;
end.
แต่Run แล้ว Error ที่ System.IO
Re: หา Path File ที่ต้องการใช้ Delphi ทำไงครับ
ที่คุณเอามาให้ดู
มันเรียกดู โฟลเดอร์ กับไฟล์
ไม่ใช้เหรอ
ส่วน System.IO;
คาดว่ามันเป็นไฟล์ ที่ต้องเอามาเพิ่มเอง
มันไม่ใช้ไฟล์ ที่ Delphi มีมาให้
หา Path มันต้อง
เช่น c:/windows/system32
ใช่ ป่าว
ผมเองก้อไม่ค่อยเก่งหรอก :D
program Project2;
{$APPTYPE CONSOLE}
uses
windows;
function GetSysDir():String;
begin
SetLength( Result, 260 );
SetLength( Result, GetSystemDirectory( PChar( Result ), Length( Result ) ) );
end;
begin
WriteLn(GetSysDir);
WriteLn;
Readln;
end.
Re: หา Path File ที่ต้องการใช้ Delphi ทำไงครับ
:-) ขอบคุณนะครับที่ช่วยตอบครับ ขอบคุณมากๆครับ