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: 1108 | Odgovora: 7 ]

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

gygy
Dragan Grbic

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

ICQ: 176982864
Sajt: www.gygy.co.nr


Profil

icon Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 12:19

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
14.11.2004. u 12:19 

reiser
Vranje

Član broj: 7895
Poruke: 1892
*.dialup.neobee.net.



Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 13:29
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.
14.11.2004. u 13:29 

bancika
Branislav Stojkovic
Nis, New York

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

ICQ: 84215453
Sajt: www.storm-software.co.yu/..


Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 16:04
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
14.11.2004. u 16:04 

reiser
Vranje

Član broj: 7895
Poruke: 1892
*.dialup.neobee.net.



Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 17:38
Vidis, na to sam potpuno zaboravio...
14.11.2004. u 17:38 

gygy
Dragan Grbic

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

ICQ: 176982864
Sajt: www.gygy.co.nr


Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 21:22
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
14.11.2004. u 21:22 

sasas
Saša Slavnić
radim za neke švabe

Član broj: 35478
Poruke: 614
195.246.3.*



Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?14.11.2004. u 21:51
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.
14.11.2004. u 21:51 

morlic
Milos Orlic
Beograd

Moderator
Član broj: 6081
Poruke: 731
*.74.eunet.yu.



Profil

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


Code:

novoime:= ChangeFileExt(fileListBox.Items[j],ExtractFileExt(fileListBox.Items[j]));
15.11.2004. u 10:00 

broker

Član broj: 2415
Poruke: 8521
212.62.59.*



Profil

icon Re: Kako resiti da se ekstenzija ne prikazuje?15.11.2004. u 10:10
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.
15.11.2004. u 10:10 

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

[ Pregleda: 1108 | Odgovora: 7 ]

Postavi temu Odgovori

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