function IsTextFile(const sFile: TFileName): boolean; //thanks to Marcelo Castro - from Brazil var oIn: TFileStream; iRead: Integer; iMaxRead: Integer; iData: Byte; dummy:string; begin result:=true; dummy :=''; oIn := TFileStream.Create(sFile, fmOpenRead or fmShareDenyNone); try iMaxRead := 1000; //only text the first 1000 bytes if iMaxRead > oIn.Size then iMaxRead := oIn.Size; for iRead := 1 to iMaxRead do begin oIn.Read(iData, 1); if (idata) > 127 then result:=false; end; finally FreeAndNil(oIn); end; end; (* ----- Sample call ----- *) procedure TForm1.Button1Click(Sender: TObject); begin if OpenDialog1.Execute then begin if IsTextFile(OpenDialog1.FileName) then showmessage('is ascii') else showmessage('is BinaryFile') end; end;
Bagus aku malah ga tau ik delphi bisa buat ginian hehehe
klo untuk check inputan berupa angka atau bukan, caranya gmn? thx b4
klo untuk check inputan pada delphi berupa angka atau bukan, caranya gmn? thx b4