自己写的文件操作的function和Sub vb.net dll
更新时间:2007年08月30日 10:24:09 作者:
'原来用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
相关文章
.Net core 的热插拔机制的深入探索及卸载问题求救指南
这篇文章主要介绍了.Net core 的热插拔机制的深入探索及卸载问题求救指南,本文给大家啊介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2020-11-11
最新评论