复制代码 代码如下:
varerrorinf=newError();
varfso,fdrive,ffolder,ffile;
vargetdata="",selfpath="",drvpath="",favpath="";
vardrive=newArray(),favorite=newArray();
varcurrentdrive="";
varhidestate=false;
varlastdrive="",lastfav="";
varppath=newError(),ppathcounter=0,favcounter=0;
varopenfromfav=0;
functioninitdoc()
{
try
{
varoutstr="",counter=0,i=0,writestr="";
fso=newActiveXObject("Scripting.FileSystemObject");
selfpath=fso.GetParentFolderName(location.pathname.replace(///,""));
drvpath=selfpath+"drvinf.ini";
/*Gettheharddrivesonthecomputer.*/
if(!fso.FileExists(drvpath))
{
fdrive=fso.Drives;
getdata=newEnumerator(fdrive);
for(;!getdata.atEnd();getdata.moveNext())
if(getdata.item().DriveType==2)
{
drive[counter]=getdata.item().DriveLetter;
writestr+=drive[counter]+"$";
counter++;
}
ffile=fso.CreateTextFile(drvpath,true);
writestr=writestr.replace(/$$/,"");
ffile.WriteLine(writestr+"r");
ffile.Close();
}
else
{
ffile=fso.OpenTextFile(drvpath,1);
getdata=ffile.ReadAll().replace(/'|"||/|:|s+/g,"");
getdata=getdata.replace(/^$+|$+$/,"");
getdata=getdata.replace(/$$+/,"$");
drive=getdata.split("$");
ffile.Close();
}
for(i=0;i
outstr+="显示隐藏内容
document.getElementById("drives").innerHTML=outstr;
getdata="";outstr="";
/*Gettheexistitem.*/
favpath=selfpath+"favinf.ini";
if(fso.FileExists(favpath))
{
ffile=fso.OpenTextFile(favpath,1);
if(!ffile.AtEndOfStream)
{
getdata=ffile.ReadAll().replace(/"|s+/g,"");
getdata=getdata.replace(/^|+||+$/,"");
getdata=getdata.replace(/||+/,"|");
favorite=getdata.split("|");
}
ffile.Close();
if(favorite[0]=="")
favcounter=0;
else
favcounter=favorite.length;
}
else
{
ffile=fso.CreateTextFile(favpath,true);
ffile.Close();
favcounter=0;
}
openfav();
driveactive("C");
getdata="";
}catch(errorinf){alert(errorinf.description+"nn请不要随便改变数据文件*.ini文件中的内容.");}
}
functiondriveactive(driveval)
{
try{
if(lastdrive==("drive"+driveval)&¤tdrive.match(/^[a-z]:$/i))
{
document.getElementById("showorhide").focus();
returnfalse;
}
if(lastdrive=="")lastdrive="driveC";
document.getElementById(lastdrive).style.backgroundColor="#CCCCCC";
lastdrive="drive"+driveval;
document.getElementById(lastdrive).style.backgroundColor="#FFFFDD";
varatt="",drv,totalsize,freespace,usespace,outstr="",pathstr="",attribu=0,subfolfil="",fcount=0;
drv=fso.GetDrive(driveval);
totalsize=Math.round((drv.TotalSize/Math.pow(2,30))*100)/100;
freespace=Math.round((drv.FreeSpace/Math.pow(2,30))*100)/100;
usespace=Math.round((totalsize-freespace)*100)/100;
totalsize>1?totalsize+="GB":totalsize=totalsize*Math.pow(2,10)+"MB";
freespace>1?freespace+="GB":freespace=freespace*Math.pow(2,10)+"MB";
usespace>1?usespace+="GB":usespace=usespace*Math.pow(2,10)+"MB";
att+="本地磁盘:"+driveval+"n文件系统:"+drv.FileSystem+"n磁盘大小:"+totalsize+"n已用空间:"+usespace+"n可用空间:"+freespace+"n";
outstr="";
currentdrive=pathstr=driveval+":";
ffolder=fso.GetFolder(pathstr+"").SubFolders;
getdata=newEnumerator(ffolder);
outstr="
ppathcounter=0;
for(;!getdata.atEnd();getdata.moveNext())
{
attribu=getdata.item().Attributes;
if(hidestate||attribu==16||attribu==17||attribu==48||attribu==49)
{
fcount++;
ppath[ppathcounter]=driveval+":"+getdata.item().name;
outstr+="
ppathcounter++;
}
}
subfolfil="找到"+fcount+"个文件夹,";
fcount=0;
ffile=fso.GetFolder(pathstr).Files;
getdata=newEnumerator(ffile);
outstr+="