zoukankan      html  css  js  c++  java
  • ExtractNewFolderPath

    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.
     
     
     





    附件列表

  • 相关阅读:
    [转载]写作经验谈--如何写一本书?
    决定写一本书
    c中自定义函数通过sizeof来输出数组的长度为何不正确?【原创】
    [转]关于PHP的漏洞以及如何防止PHP漏洞?
    [转]PHP安全之防止你的源代码或重要配置信息暴露在外
    PHPUnit 单元测试框架(鸡肋)
    [转]避免PHP-FPM内存泄漏导致内存耗尽
    [转]PHP ffmpeg截取视频指定帧为图片,获取rotation信息并旋转
    ThinkPHP 缓存 以及Zend OPCache提升PHP性能
    简单测漏 语句
  • 原文地址:https://www.cnblogs.com/xe2011/p/3383173.html
Copyright © 2011-2022 走看看