创建了一个多级文件夹,可以往里面写入文件,但想控制它的大小。
用一个监视程序实现,过程不是很清楚,请高手们指教,谢谢了:)

解决方案 »

  1.   

    http://dev.csdn.net/article/3/3487.shtm
    利用Windows外壳扩展保护文件夹
      

  2.   

    http://dev.csdn.net/article/3/3545.shtm
      利用未公开函数实现Shell操作监视
      

  3.   


    //------------------------------------------------------------------------------
    //
    //  取指定文件的大小
    //
    //  参数   :
    //         FileName     :       指定的文件名(带路径)
    //
    //  返回值 :
    //         成功: 返回文件的大小 (单位 : KB)
    //         失败: 返回 -1
    //
    //------------------------------------------------------------------------------
    function GetFileSize(const FileName: String): LongInt;
    var
      F: File of Byte;
    begin
      //文件关联
      AssignFile(F, FileName);
      Try
        Reset(F);           //打开文件
        Try
          //返回大小 KB
          Result := FileSize(F) DIV 1024;
        Finally;
          CloseFile(F);     //关闭文件
        end;
      Except;
        Result := -1;       //失败
      end;
    end;
      

  4.   

    遍历文件夹函数function SearchFile( RootPath, FileName: String; var lstFile: TStrings ):Boolean;//---------------------------------------------------------------------------
    //
    //      查找一个目录下的文件,写在lstFile
    //
    //---------------------------------------------------------------------------
    function SearchFile( RootPath, FileName :String; var lstFile: TStrings ):Boolean;
    var
      FileRec     : TSearchRec;
    begin
      if RootPath[Length(RootPath)] <>'\' then
         RootPath := RootPath +'\';  if ( FindFirst( RootPath + FileName, faAnyFile, FileRec ) =0 ) then
      begin
        lstFile.Add( RootPath + FileRec.Name );
        while ( FindNext( FileRec ) = 0 ) do
        begin
          lstFile.Add( RootPath + FileRec.Name );
        end;
      end;
      FindClose( FileRec );  Result := True;
    end;使用方法:
    var
      lstFiles :TString;
    begin
      lstFiles := TStringList.Create;
      SearchFile( 'C:\', *.*, lstFiles );
      
      // c盘下的所有文件名称都在lstFiles中了。
      // 文件名一就是:lstFiles.Strings[0];
      // 文件名二就是:lstFiles.Strings[1];
    end;
      

  5.   

    http://search.csdn.net/Expert/topic/1382/1382140.xml?temp=.9812128
    http://search.csdn.net/Expert/topic/1079/1079045.xml?temp=.2320673
    http://search.csdn.net/Expert/topic/1945/1945216.xml?temp=.3062555