Arsip: [tanya] bagaimana load file di listbox tanpa full path name
more 12 years ago
andrypein
ini ss nya
ini kodingnya
var
namatema : string;
begin
for namatema in TDirectory.GetFiles((ExtractFilePath(ParamStr(0)))+'style','*'+TStyleEngine.FileExtension) do
ListBoxtema.Items.Add(namatema);
itu kode malah menghasilkan full directory nya
yang ane pengen cuma si nama file nya aja
:roll:
semua udah dicoba,dari application.exename ,extract ini itu :(
more 12 years ago
halimanh
salah satu cara bisa bikin fungsi untuk mengambil nama filenya aja dari namatema
uses StrUtils;
function CariNamaFile(const path : string) : string;
var
posisi, posisiAkhir : Integer;
begin
posisi := Posex('', Path, 1);
posisiAkhir := posisi;
while posisi <> 0 do
begin
posisi := Posex('', Path, posisi+1);
if posisi <> 0 then posisiAkhir := posisi;
end;
if posisiAkhir > 0 then
result := AnsiMidStr(path, posisiAkhir+1, Length(path)-posisiAkhir)
else
result := '---'; //nggak ketemu
end;
terus makenya
...
for namatema in TDirectory.GetFiles((ExtractFilePath(ParamStr(0)))+'style',''+TStyleEngine.FileExtension) do
ListBoxtema.Items.Add(cariNamaFile(namatema));
...
@andrypein: ini ss nya ini kodingnyaitu kode malah menghasilkan full directory nya yang ane pengen cuma si nama file nya aja :roll: semua udah dicoba,dari application.exename ,extract ini itu :(var namatema : string; begin for namatema in TDirectory.GetFiles((ExtractFilePath(ParamStr(0)))+'style',' '+TStyleEngine.FileExtension) do ListBoxtema.Items.Add(namatema);
more 12 years ago
tomxpatra
Procedure GetFileList(var aFiles : TStringList; sPath : string; sMask : string = '. ');
var
iIndex : Integer;
SearchRec : TSearchRec;
begin
if aFiles = Nil then
aFiles := TStringList.Create;
if sPath[Length(sPath)] <> '' then
sPath := sPath + '';
iIndex := FindFirst(sPath+sMask, faArchive, SearchRec);
while iIndex = 0 do
begin
aFiles.Add(SearchRec.Name);
iIndex := FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
ane pake procedure di atas dari hasil googling bisa dimodifiksi jadi funcion. itu hasilnya balik lagi ke parameter aFiles lho nanti tinggal pindahkan hasil dari aFiles (TStringList) ke list box. ok
mudah mudah membantu[/pas]
more 12 years ago
andrypein
terimakasih semua nya
ternyata kesalahan ane doank
panik jadi ga konsen :lol:
working gan
ane lupa nambahin extractfilename
:D
more ...
- Pages:
- 1
reply |
Report Obsolete
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 4 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 12 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 12 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 12 years ago
Random Topic
- Bikin Stack lewat Delphi ??
by kacungdelphi24 in Bedah Kasus more 16 years ago - code huffman
by andi_meno in Hal umum tentang Pascal Indonesia more 16 years ago - Pemula Mohon Bantuan
by afry in Tip n Trik Pemrograman more 15 years ago - My Free Component
by Starboard in Hal umum tentang Pascal Indonesia more 18 years ago - membuat ID otomatis pada Mysql
by utuhhirang in Tip n Trik Pemrograman more 15 years ago - Cache update di zeos
by dannyong1999 in MySQL more 17 years ago - tombol tab...?
by aireda in Tip n Trik Pemrograman more 17 years ago - MaskEdit
by syntax_error in Tip n Trik Pemrograman more 16 years ago - Tanya tentang enkripsi (baru belajar neh)
by goosemunk in Tutorial & Community Project more 18 years ago - import data XML
by delphi1st in Tip n Trik Pemrograman more 18 years ago