自己写的文件操作的function和Sub vb.net dll
程序员文章站
2022-05-03 12:58:26
'原来用vb写的封装成dll供asp使用,后来升级到vb.net '这个是我以前写的电影站影片处理的一部份,程序挺简单的,没怎么注释,大家对付看 'program ...
'原来用vb写的封装成dll供asp使用,后来升级到vb.net
'这个是我以前写的电影站影片处理的一部份,程序挺简单的,没怎么注释,大家对付看
'program by someeyes
'需要声明imports system.io命名空间
public function myfileexists(byval pathname as string) as string '检查文件是否存在
if file.exists(pathname) = false then
myfileexists = "<font color=""red"">文件丢失</font>"
else
myfileexists = "<font color=""#0066ff"">文件存在</font>"
end if
end function
private sub mycreatdirectory(byval pathname as string) '创建文件夹
try
if directory.exists(pathname) = false then
directory.createdirectory(pathname)
end if
catch e as exception
myerrmsg = myerrmsg & "创建" & pathname & "文件夹的时候出现一个意外的错误."
myerrmsg = myerrmsg & e.tostring
httpcontext.current.response.write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")
end try
end sub
private sub mydeldirectory(byval pathname as string) '删除文件夹
try
if directory.exists(pathname) = true then
directory.delete(pathname)
end if
catch e as exception
myerrmsg = myerrmsg & "删除" & pathname & "文件夹的时候出现一个意外的错误."
myerrmsg = myerrmsg & e.tostring
httpcontext.current.response.write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")
end try
end sub
private sub mymovefile(byval pathname as string, byval target as string) '移动文件夹
try
file.move(pathname, target)
catch e as exception
myerrmsg = myerrmsg & "从" & pathname & "移动文件到" & target & "的时候出现一个意外的错误."
myerrmsg = myerrmsg & e.tostring
httpcontext.current.response.write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")
end try
end sub
private sub mycopyfile(byval fsource as string, byval fdestination as string)
try
file.copy(fsource, fdestination, false)
catch e as exception
myerrmsg = myerrmsg & "从" & fsource & "复制文件到" & fdestination & "的时候出现一个意外的错误."
myerrmsg = myerrmsg & e.tostring
httpcontext.current.response.write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")
end try
end sub
'这个是我以前写的电影站影片处理的一部份,程序挺简单的,没怎么注释,大家对付看
'program by someeyes
'需要声明imports system.io命名空间
public function myfileexists(byval pathname as string) as string '检查文件是否存在
if file.exists(pathname) = false then
myfileexists = "<font color=""red"">文件丢失</font>"
else
myfileexists = "<font color=""#0066ff"">文件存在</font>"
end if
end function
private sub mycreatdirectory(byval pathname as string) '创建文件夹
try
if directory.exists(pathname) = false then
directory.createdirectory(pathname)
end if
catch e as exception
myerrmsg = myerrmsg & "创建" & pathname & "文件夹的时候出现一个意外的错误."
myerrmsg = myerrmsg & e.tostring
httpcontext.current.response.write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")
end try
end sub
private sub mydeldirectory(byval pathname as string) '删除文件夹
try
if directory.exists(pathname) = true then
directory.delete(pathname)
end if
catch e as exception
myerrmsg = myerrmsg & "删除" & pathname & "文件夹的时候出现一个意外的错误."
myerrmsg = myerrmsg & e.tostring
httpcontext.current.response.write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")
end try
end sub
private sub mymovefile(byval pathname as string, byval target as string) '移动文件夹
try
file.move(pathname, target)
catch e as exception
myerrmsg = myerrmsg & "从" & pathname & "移动文件到" & target & "的时候出现一个意外的错误."
myerrmsg = myerrmsg & e.tostring
httpcontext.current.response.write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")
end try
end sub
private sub mycopyfile(byval fsource as string, byval fdestination as string)
try
file.copy(fsource, fdestination, false)
catch e as exception
myerrmsg = myerrmsg & "从" & fsource & "复制文件到" & fdestination & "的时候出现一个意外的错误."
myerrmsg = myerrmsg & e.tostring
httpcontext.current.response.write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")
end try
end sub
上一篇: 全球最大车展