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. Linux(Fedora)下NodeJs升级最新版本(制定版本)

    Linux(Fedora)下NodeJs升级最新版本(制定版本) 首先安装n模块: npm install -g n 升级node.js到最新稳定版 n stable 升级node.js到制定版本 n ...

  2. php脚本业务逻辑

    设置时区 设置执行不超时 设置根目录常量 引入配置文件(自定义/模板) 错误记录 定义业务类 执行业务类::run() 数据库单例初始化(连接) 日志单例初始化(引入日志类,配置日志路径,日志开关) ...

  3. 无Xaml的WPF展示

    我们创建一个wpf应用程序,我们把里面的xaml文件全部删除,添加一个新类: 如下图: 然后我们cs文件中的代码: using System; using System.Collections.Gen ...

  4. OC语言-01类和对象

    // cc 文件名.m -framework Foundation 编译链接 #import <Foundation/Foundation.h> //枚举性别 typedef enum{ ...

  5. 趣味C程序100.1 .1 绘制余弦曲线

    说明:1.本问题来源于<C语言经典.趣味.实用程序设计编程百例精解>,所有程序为本人自己编写.与原程序不同之处作有标记. 2.本系列所有程序均使用codeblocks编译,操作系统为Win ...

  6. [BZOJ 1025] [SCOI2009] 游戏 【DP】

    题目链接:BZOJ - 1025 题目分析 显然的是,题目所要求的是所有置换的每个循环节长度最小公倍数的可能的种类数. 一个置换,可以看成是一个有向图,每个点的出度和入度都是1,这样整个图就是由若干个 ...

  7. Servo: The Embeddable Browser Engine

    Embedding, in the context of this article, is the process of hosting a web rendering engine inside a ...

  8. UIImageView之我的动画为什么停了?UIImageView, highLighted,animationImages

    如果你的动画总是停了!停了!停了!不管你想不想都停,这里有个参考,你可以看看!这只是一种可能性!!! 受最近看到段子影响,画风略诡异,不喜勿喷. 最近在“刻”动画!!! 为什么是“刻”,动画写了3周啊 ...

  9. java.util.regex.Pattern的应用

    java.util.regex.Pattern 正则表达式的一种已编译的实现. 正则表达式通常以字符串的形式出现,它首先必须被编译为Pattern类的一个实例.结果模型可以用来生成一个Matcher, ...

  10. Eclipse配置Git

    一.Eclipse上安装GIT插件EGit Eclipse的版本eclipse-java-helios-SR2-win32.zip(在Eclipse3.3版本找不到对应的 EGit插件,无法安装) E ...