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.
     
     
     





    附件列表

  • 相关阅读:
    【YBTOJ】【Luogu P2605】[ZJOI2010]基站选址
    【CodeForces 261D】Maxim and Increasing Subsequence
    【Luogu P4140】奇数国
    【YBTOJ】【Luogu P6474】[NOI Online #2 入门组] 荆轲刺秦王
    【YBTOJ】【Luogu P4667】[BalticOI 2011 Day1]Switch the Lamp On
    Tools分类随笔链接整理贴(不定期更新)
    Vs2012安装介绍
    VC 修改对话框默认类名
    扫雷小游戏_通过爆破手段强制胜利
    C++ STL(十)算法
  • 原文地址:https://www.cnblogs.com/xe2011/p/3383173.html
Copyright © 2011-2022 走看看