Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Kako resiti da se ekstenzija ne prikazuje?

[es] :: Pascal / Delphi / Kylix :: Kako resiti da se ekstenzija ne prikazuje?

[ Pregleda: 2772 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

gygy
Dragan Grbic

Član broj: 7861
Poruke: 205
*.sezampro.yu.



Profil

icon Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 12:19 - pre 236 meseci
Koristim:
Edit: TEdit
DriveComboBox1: TDriveComboBox
DirectoryListBox: TDirectoryListBox
Brojfajlova: TLabel
grid: TStringGrid
Directory: TDirectoryListBox
FileListBox: TFileListBox
Code:

procedure TForm1.Button1Click(Sender: TObject);
var
   rootDir:string;
procedure bros(const root:string);
var
   i,j,dirIterate:word;
   subdirs:TstringList;
     a,b:string;
begin
   subdirs:=Tstringlist.Create;
   Directory.Directory:=root;
   Directory.OpenCurrent;
a:=floattostr(j);
   if FileListBox.items.count>0 then
      for j:=0 to FileListBox.items.count-1 do
         begin
         grid.cells[0,grid.RowCount-1]:=fileListBox.Items[j];
         grid.cells[1,grid.RowCount-1]:=root;

         grid.cells[2,grid.RowCount-1]:=NazivFajla(a);
         grid.RowCount:=grid.RowCount+1;
         end;
  if not(Directory.ItemIndex=Directory.Items.Count-1) then
      begin
      for i:=Directory.ItemIndex+1 to Directory.Items.count-1 do
         begin
         if Directory.itemindex=0 then
             subdirs.add(Directory.Directory+Directory.Items[i]) 
           else
             subdirs.add(Directory.Directory+'\'+Directory.Items[i]);
         end;

      for dirIterate:=0 to subdirs.Count-1 do
         bros(subdirs[dirIterate]);
      end;
   subdirs.Free;
end;
begin
FileListBox.Mask:='*.'+Edit.text;
grid.RowCount:=2;
grid.Cells[0,1]:='';
grid.Cells[1,1]:='';
grid.Cells[0,0]:='Naziv fajla';
grid.Cells[1,0]:='Lokacija';
screen.Cursor:=-11;
bros(DirectoryListBox.Directory);
if grid.RowCount > 2 then
   grid.RowCount:=grid.RowCount-1;
if grid.cells[0,1]<>'' then
   Brojfajlova.Caption:='Ukupan broj pronadjenih fajlova: '+inttostr(grid.rowcount-1)
else
   Brojfajlova.Caption:='Ukupan broj pronadjenih fajlova: 0';
screen.Cursor:=0;
end;

Ovaj gore navedeni kod koristim i sve lepo ferca. All... Program u prvoj koloni prikazuje naziv fajla, a u drugoj lokaciju. Samo zelim da ne prikazuje ekstenziju fajla.

Npr u prvoj koloni
Anastacia - Left Outside Alone.mp3.....da bude.....Anastacia - Left Outside Alone
Blacke Eyed Peas - Shut Up.mp3.........da bude.....Blacke Eyed Peas - Shut Up
znaci da nema *.mp3

Da li neko zna kako da ovo resim?
Unapred hvala!!!
GYGY
 
Odgovor na temu

reiser

Član broj: 7895
Poruke: 2314



+102 Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 13:29 - pre 236 meseci
Recimo da ti se ime fajla sa extenzijom nalazi u promenljivoj ime_fajla :

Code:

var
  ime_bez_ext : String;
begin
  ime_bez_ext := Copy(ime_fajla, 1, Length(ime_fajla) - 4);
end;

Ovaj kod u stvari uzima string cija je duzina za 4 karaktera manja od imena fajla.

Mozes i sa Delete() funkcijom.
 
Odgovor na temu

bancika
Branislav Stojkovic

Član broj: 24844
Poruke: 631
*.vdial.verat.net.

Sajt: www.diy-fever.com


+1 Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 16:04 - pre 236 meseci
a sta ako je extenzija .db, ili .html???

ovo je univerzalno

Code:

  Delete(s, Length(s) - Length(ExtractFileExt(s)) + 1, Length(ExtractFileExt(s)) )

Ride the rainbow, crack the sky

DIY gitare, pojacala i efekti www.diy-fever.com
 
Odgovor na temu

reiser

Član broj: 7895
Poruke: 2314



+102 Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 17:38 - pre 236 meseci
Vidis, na to sam potpuno zaboravio...
 
Odgovor na temu

gygy
Dragan Grbic

Član broj: 7861
Poruke: 205
*.sezampro.yu.



Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 21:22 - pre 236 meseci
Ovo ferca ali ako je ekstenzija sa 3 slova:
Code:
...
procedure TForm1.Button1Click(Sender: TObject);
var
  ime_fajla : String;
   rootDir:string;
procedure browsesub(const root:string);
var
   i,j,dirIterate:word;
   subdirs:TstringList;
begin
   subdirs:=Tstringlist.Create;
   Directory.Directory:=root;
   Directory.OpenCurrent;
   if FileListBox.items.count>0 then
      for j:=0 to FileListBox.items.count-1 do
         begin
         ime_fajla:=fileListBox.Items[j];
         grid.cells[0,grid.RowCount-1]:=Copy(ime_fajla, 1, Length(ime_fajla) - 4);
...

A ovo nece da moze:
Code:
...
procedure TForm1.Button1Click(Sender: TObject);
var
  s: String;
   rootDir:string;
procedure browsesub(const root:string);
var
   i,j,dirIterate:word;
   subdirs:TstringList;
begin
   subdirs:=Tstringlist.Create;
   Directory.Directory:=root;
   Directory.OpenCurrent;
   if FileListBox.items.count>0 then
      for j:=0 to FileListBox.items.count-1 do
         begin
         s:=fileListBox.Items[j];
         grid.cells[0,grid.RowCount-1]:=Delete(s, Length(s) - Length(ExtractFileExt(s)) + 1, Length(ExtractFileExt(s)) );
...

sta je neispravno?
hvala!

GYGY
 
Odgovor na temu

sasas
Saša Slavnić
radim za neke švabe

Član broj: 35478
Poruke: 617
195.246.3.*



Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 21:51 - pre 236 meseci
Ovo:

Code:

         s:=fileListBox.Items[j];
         grid.cells[0,grid.RowCount-1]:=Delete(s, Length(s) ...


zameni sa:

Code:

         s:=fileListBox.Items[j];
         Delete(s, Length(s) - Length(ExtractFileExt(s)) + 1, Length(ExtractFileExt(s)));
         grid.cells[0,grid.RowCount-1]:= s;



Ovo je samo ako imas problem sa brisanjem extenzije, ostatak kooda nisam gledao...

ss.
When something is hard to do, then it's not worth doing.
 
Odgovor na temu

morlic
Milos Orlic
Beograd

Član broj: 6081
Poruke: 735
*.74.eunet.yu.



+1 Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?15.11.2004. u 10:00 - pre 236 meseci
Sta je bre ovo :), takmicenje za najteze resenje? Probaj ovo:


Code:

novoime:= ChangeFileExt(fileListBox.Items[j],ExtractFileExt(fileListBox.Items[j]));
 
Odgovor na temu

broker

Član broj: 2415
Poruke: 8514
212.62.59.*



+11 Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?15.11.2004. u 10:10 - pre 236 meseci
Na brzinu sam iscupao is Help-a, neke od funkcija za manipulaciju imenom datoteke.
Da ne trosite vreme na parsiranje :)


ChangeFileExt function
Changes the extension of a file name.

ExpandFileName function
Returns the full path name for a relative file name.

ExtractFileDir function
Extracts the drive and directory parts from FileName.

ExtractFileDrive function
Returns the drive portion of a file name.

ExtractFileExt function
Returns the extension portions of a file name.

ExtractFileName function
Extracts the name and extension parts of a file name.

ExtractFilePath function
Returns the drive and directory portions of a file name.

ExtractRelativePath function
Returns a relative path name, relative to a specific base directory.
 
Odgovor na temu

[es] :: Pascal / Delphi / Kylix :: Kako resiti da se ekstenzija ne prikazuje?

[ Pregleda: 2772 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.