有什么函数可以把后缀名去掉呢?望告知道,谢谢!酬谢!
解决方案 »
- fastreport升级也太频繁了!
- 什么是Geo++?
- 两台很远的电脑(大约2000KM),如何联网?有哪些方法?
- 本人初学DELPHI:关于TWEBbrowser如何控制javascript的close发生,帮我UP, 入即给分
- 在哪里能找到这样的控件?
- 还有没有别的TreeView了?好看一点的有么?
- 两个轻量级别的问题。请大家关注。
- 为什么用TImage组件做画图软件,一画图时在闪....30分
- stringgrid的onrowmoved怎么用?
- 求 delphi 7 qrcode 解码 demo
- 如何发布ASA(Adaptive Server Anywhere 6.0)数据库的程序(指不需安装ASA,只发布一个dbeng6.exe文件或其它很少的文件)并且在Delphi中怎
- 小问题
ExtractFileExt
ExtractFilePath配合着用,
文件名 - 文件扩展名
ExtractFileExt
ExtractFilePath
var
iBegin, iEnd: Integer;
begin
iBegin := LastDelimiter(PathDelim + DriveDelim, FileName);
iEnd := LastDelimiter('.' + PathDelim + DriveDelim, FileName);
if (iEnd > 0)and(FileName[iEnd] = '.') then
Result := Copy(FileName, iBegin+1, iEnd-iBegin-1)
else
Result := Copy(FileName, iBegin+1, MaxInt);
end;
ExtractFileExt
ExtractFilePath好象直接就能用啊
var
I: Integer;
begin
I := LastDelimiter('.' + PathDelim + DriveDelim,Filename);
if (I = 0) or (FileName[I] <> '.') then I := MaxInt;
Result := Copy(FileName, 1, I - 1) + Extension;
end;SysUtils单元中,改下:function DelFileExt(const FileName): string;
var
I: Integer;
begin
I := LastDelimiter('.' + PathDelim + DriveDelim,Filename);
if (I = 0) or (FileName[I] <> '.') then I := MaxInt;
Result := Copy(FileName, 1, I - 1);
end;
我说点简单的,
如果你保证后缀是三个字母
fname:=copy(fname,1,length(fname)-4);
如果不能保证是三个就用
for i:=length(fname) downto 1 do
if fname[i]='.' then
begin
id:=i;
exit;
end;
fname:=copy(fname,1,length(fname)-id);
先ExtractFileName得到name再name:=copy(name,1,length(name)-4);
//也去后缀function DelFileExt(const FileName : String ): string;
var
I: Integer;
begin
i := Pos('.',FileName) ;
if I = 0 then Result := FileName
Else
Result := Copy(FileName, 1, I - 1);
end;
你的这个程序没有考虑文件名中有'.'的情况哦?
---------------------function DelFileExt(FileName : String ): string;
var
I,j: Integer;
s : String ;
Source : String ;
begin
Source := FileName ;
j := 0 ;
I := 1 ;
while I <> 0 do
begin
I := Pos('.',FileName) ;
if I = 0 then
begin
I := J ;
Break ;
end
Else
begin
S := Copy(FileName,(i+1),(Length(FileName) - I)) ;
FileName := S ;
j := I + J ;
End;
end;
FileName := Source ;
if I = 0 then Result := FileName
Else
Result := Copy(FileName, 1, I - 1);
end;