unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  HtmlFileName: string; // "D:\C++Builder学习大全中文版\index.htm"
  _filesFolder: string; // "D:\C++Builder学习大全中文版\"
  _filesFolderName: string; // "index_files"
  _filesFolderPath: string; // "D:\C++Builder学习大全中文版\index_files"
begin
  HtmlFileName := 'D:\C++Builder学习大全中文版\index.htm';
  _filesFolder := ExtractFilePath(HtmlFileName);
  _filesFolderName := ChangeFileExt(ExtractFileName(HtmlFileName), '') +
    '_files'; // INDEX_files
  _filesFolderPath := _filesFolder + _filesFolderName;
  Memo1.lines.Add(_filesFolderPath);
end;

{
  // "D:\C++Builder学习大全中文版\index.htm"
  // "D:\C++Builder学习大全中文版\"
  // "index_files"
  // "D:\C++Builder学习大全中文版\index_files"
  Caption:=ExtractNewFolderPath('D:\C++Builder学习大全中文版\index.htm','_files');
  "D:\C++Builder学习大全中文版\index_files"
}
function ExtractNewFolderPath(FileName: string; NewText: string): string;
var
  _filesFolder: string; // "D:\C++Builder学习大全中文版\"
  _filesFolderName: string; // "index_files"
  _filesFolderPath: String;
begin
  _filesFolder := ExtractFilePath(FileName);
  _filesFolderName := ChangeFileExt(ExtractFileName(FileName), '') + NewText;
  _filesFolderPath := _filesFolder + _filesFolderName;
  Result := _filesFolderPath;
end;

//  if not DirectoryExists(_filesFolderPath) then
//    CreateDir(_filesFolderPath);

procedure TForm1.Button2Click(Sender: TObject);
var
  s, s1, s2: string;
begin
  s := 'D:\C++Builder学习大全中文版\index.htm';
  s1:=ExtractNewFolderPath(s,'_files');
  s2 := ExtractNewFolderPath(s, '_AttachMents');
  Memo1.lines.Add(s);
  Memo1.Lines.Add(s1);
  Memo1.lines.Add(s2);
end;

end.

 
 
 

附件列表

ExtractNewFolderPath的更多相关文章

随机推荐

  1. WinForm控件复杂数据绑定常用数据源(对Combobox,DataGridView等控件DataSource赋值的多种方法)

    开始以前,先认识一下WinForm控件数据绑定的两种形式,简单数据绑定和复杂数据绑定. 1) 简单数据绑定 简单的数据绑定是将用户控件的某一个属性绑定至某一个类型实例上的某一属性.采用如下形式进行绑定 ...

  2. AS3的数据类型和定义

    AS3的数据类型分: 基元数据类型:Boolean  int(整数)  Number(长的浮点数)  unit(很大的正整数)  String 复杂数据类型:Arrary  Date  Error   ...

  3. IS about 64bit system

    This function supports the 64-bit parts of the registry by using the REGDB_OPTION_WOW64_64KEY option ...

  4. Git中从远程的分支获取最新的版本到本地

    Git中从远程的分支获取最新的版本到本地有这样2个命令: 1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge    git fetch origin mastergit l ...

  5. 《C和指针》章节后编程练习解答参考——6.6

    <C和指针>——6.6 题目: 在指定的下限.上限之间使用数组方法查找质数,并将质数提取出来. 要求: 略 解答代码: #include <stdio.h> #define U ...

  6. sql如果存在就修改不存在就新增

    FROM 表名 WHERE 条件) UPDATE 表名 SET 字段=值 WHERE 条件 ELSE INSERT INTO 表名(字段) VALUES(值) 真实使用举例: from [UserRu ...

  7. App接口设计原则-b

    1.记住密码不是真的让你记住密码,这里仅仅指的是一种自动登录的手段.不管在任何地方,明文存储的密码都是安全隐患,是必须尽量避免的.你可以采用某种方式对用户名.密码以及时间戳(重要)进行签名,再次登录时 ...

  8. PHP-mac下的配置及运行

    Here's another option, from the guys from liip, here. This is a PHP package that comes pre-built for ...

  9. 【HDOJ】2966 In case of failure

    KD树,这东西其实在ML经常被使用,不过30s的时限还是第一次见. /* 2966 */ #include <iostream> #include <string> #incl ...

  10. 凯撒密码 CH Round #57 - Story of the OI Class

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2357%20-%20Story%20of%20the%20OI%20Class/凯撒密码 题解:刚开始想map, ...