用asp整理磁盘文件[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 chenxingbai 的 blog

机器的文件太多,需要整理一下,该如何做呢?????

本文以整理图片文件为例,给大家一点思路
代码的运行环境:iis5.0+sql server2000
数据库脚本:

if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[insertpic]') and objectproperty(id, n'isprocedure') = 1)
drop procedure [dbo].[insertpic]
go

if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[showpage]') and objectproperty(id, n'isprocedure') = 1)
drop procedure [dbo].[showpage]
go

if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[picpath]') and objectproperty(id, n'isusertable') = 1)
drop table [dbo].[picpath]
go

create table [dbo].[picpath] (
 [id] [int] identity (1, 1) not null ,
 [path] [varchar] (100) collate chinese_prc_ci_as null
) on [primary]
go

set quoted_identifier off
go
set ansi_nulls off
go

--作用:插入记录
create procedure [insertpic]
(
--路径--
@path  varchar(100)
)
 as
insert picpath(path) values(@path)
go
set quoted_identifier off
go
set ansi_nulls on
go

set quoted_identifier off
go
set ansi_nulls off
go

/*
'# 过程:showpage
'# 描述:用来记录集分页
'# 参数: - pagenum (页码)
'# 返回:-两个记录集,第一个记录集包含两个字段(总页数),第二个记录集为数据库返回给程序要显示的数据
'# 作者:zhengs
'# 日期:2002-08-27

*/

create procedure showpage
----页码
@pagenum int
as
set nocount  on
declare
@pagecount int,
@ifrom int,
@irowcount int,
@dpicid int

 

----计算该页起始的偏移量
if @pagenum <= 0
 set @pagenum = 1

set @ifrom = 10 * (@pagenum - 1) + 1


----判断传入的页码是否有效
select @irowcount = count(id) from picpath ----取得图片数
set @pagecount = @irowcount / 10 ----计算图片页数

if @irowcount %10> 0
         set @pagecount = @pagecount + 1

          if @irowcount < @ifrom
             begin
       set @ifrom = @irowcount - 10
             end
      if @ifrom<0
      select @ifrom=0
      set rowcount @ifrom
      select @dpicid = id from picpath order by id desc
      set rowcount 0

----取得图片列表
      select @pagecount as pagecount
      select top 10 *  from  picpath where  id <= @dpicid order by  id desc

      set nocount  off
      sp_end:
select @pagecount as pagecount
set nocount  off
go
set quoted_identifier off
go
set ansi_nulls on
go

搜索并存储到数据库
search.asp

<%@language="vbscript" %>
<%
'***********************************************************************************

' 文件名.........: search.asp
' 作者...........: cxb
' 说明...........: 搜索并存储到数据库
' 注意...........:
' 版权...........: copyright (c) 2000, netdragon software.
' 修改记录.......: 时间         人员     备注
'                  ---------     -------  -------------------------------------------
'                  2003-09-26    陈兴柏   创建文件

'***********************************************************************************
server.scripttimeout=500
dim a,b
'检测时间参数
a=timer
dim conn,strconn
set conn = server.createobject("adodb.connection")
strconn = "provider=sqloledb;data source=127.0.0.1;initial catalog=search;user id=sa;password=196881"
conn.open strconn

const adcmdstoredproc = &h0004
const adparaminput = &h0001
const advarchar = 200

'# --------------------------------------------------------------------------
'# 函数:getfileextname
'# 描述:获得文件是否为图片文件
'# 参数:--fname
'# 返回:--true or false
'# 作者:cxb
'# 日期:2003-9-26
'#--------------------------------------------------------------------------
function getfileextname(fname)
 
 if instr(fname,".gif") or instr(fname,".gif")  or instr(fname,".jpg") or instr(fname,".jpg") or instr(fname,".bmp")  or instr(fname,".bmp")  then
     getfileextname=true
 else
  getfileextname=false
 end if
end function


'# --------------------------------------------------------------------------

本文关键:fso ,asp,文件
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top