首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

怎么获取Internet临时文件中某文件的大小?(200分+100RMB)

2012-04-20 
如何获取Internet临时文件中某文件的大小?(200分+100RMB)http://topic.csdn.net/u/20120314/20/5c2b87bb-b

如何获取Internet临时文件中某文件的大小?(200分+100RMB)
http://topic.csdn.net/u/20120314/20/5c2b87bb-b5ff-4f16-9f64-bb59c2be9be3.html
以前提问过一次,但是无解。现在若有人能解决,一并结贴。之前遗留的问题是,普通的文件夹里可以正常取得,但是IE临时文件夹就不行,不知道有什么特殊性?能解决此问题的高手请加我扣扣:一零九九七三。200分都给你,另用淘宝转账100RMB!谢谢。

[解决办法]
为了100块。 费了半天的劲。试出来了。嘿嘿。
用 FindFirst, FindNext 递归一下,就能找到。
你找不到的原因,我知道了。因为这个图片在IE下载后。就从a.jpg 变成 a[1].jpg了

Delphi(Pascal) code
unit Main;interfaceuses  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Masks;type  TForm3 = class(TForm)    Button1: TButton;    Memo1: TMemo;    Edit1: TEdit;    Edit2: TEdit;    procedure Button1Click(Sender: TObject);  private    function FindMyFile(const FilePath, FileName: string): integer;  public    { Public declarations }  end;var  Form3: TForm3;var  myFileName, myFileExt: string;implementationuses Registry;{$R *.dfm}function GetIeTempFilePath(): string;var reg: Tregistry;  KeyList: TStringList;  i: Integer;begin  reg := Tregistry.create;  KeyList := TStringList.Create;  reg.RootKey := HKEY_CURRENT_USER;  reg.openkey('Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', False);  reg.GetValueNames(KeyList);  for i := 0 to KeyList.Count - 1 do  begin    if KeyList[i] = 'Cache' then    begin      Result := reg.ReadString(KeyList[i]);      Exit;    end;  end;  reg.CloseKey;  reg.free;  KeyList.Free;end;function TForm3.FindMyFile(const FilePath, FileName: string): integer;var  sr: TSearchRec;begin  Result := -1;  if FindFirst(FilePath + '\*.*', faAnyFile, sr) = 0 then  begin    repeat      if(sr.Name <> '.') and (sr.Name <> '..') then        if (FileGetAttr(FilePath + '\' + sr.Name) and faDirectory) = faDirectory then        begin          FindMyFile(FilePath + '\' + sr.Name, FileName);        end        else        begin          //Memo1.Lines.Add(Format('%20s - %d', [FilePath + '\' + sr.Name, sr.Size]));          if ExtractFileExt(sr.Name) = myFileExt then            if Pos(UpperCase(FileName), UpperCase(sr.Name)) > 0 then            begin              Memo1.Lines.Add(Format('%20s - %d', [FilePath + '\' + sr.Name, sr.Size]));              Result := sr.Size;              Break;            end;        end;    until FindNext(sr) <> 0;  end;  FindClose(sr);end;procedure TForm3.Button1Click(Sender: TObject);var  filePath: string;begin  filePath := GetIeTempFilePath;  Memo1.Clear;  myFileName := Edit1.Text;  myFileExt := Edit2.Text;  FindMyFile(filePath, myFileName);  ShowMessage('查找完成');end;end. 

热点排行