服务器之家

服务器之家 > 正文

自己写的文件操作的function和Sub vb.net dll

时间:2019-10-10 10:39     来源/作者:asp代码网

'原来用VB写的封装成dll供asp使用,后来升级到vb.net

'这个是我以前写的电影站影片处理的一部份,程序挺简单的,没怎么注释,大家对付看

'programbysomeeyes

'需要声明ImportsSystem.IO命名空间

  1. Public Function myFileExists(ByVal pathName As String) As String '检查文件是否存在  
  2.         If File.Exists(pathName) = False Then  
  3.             myFileExists = "<font color=""Red"">文件丢失</font>"  
  4.         Else  
  5.             myFileExists = "<font color=""#0066ff"">文件存在</font>"  
  6.         End If  
  7.     End Function  
  8.  
  9.     Private sub myCreatDirectory(ByVal pathName As String) '创建文件夹  
  10.         Try  
  11.             If Directory.Exists(pathName) = False Then  
  12.                 Directory.CreateDirectory(pathName)  
  13.             End If  
  14.         Catch e As Exception  
  15.             myErrMsg = myErrMsg & "创建" & pathName & "文件夹的时候出现一个意外的错误."  
  16.             myErrMsg = myErrMsg & e.ToString  
  17.             HttpContext.Current.Response.Write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")  
  18.         End Try  
  19.  
  20.     End Sub  
  21.  
  22.     Private Sub myDelDirectory(ByVal pathName As String) '删除文件夹  
  23.  
  24.         Try  
  25.             If Directory.Exists(pathName) = True Then  
  26.                 Directory.Delete(pathName)  
  27.             End If  
  28.         Catch e As Exception  
  29.             myErrMsg = myErrMsg & "删除" & pathName & "文件夹的时候出现一个意外的错误."  
  30.             myErrMsg = myErrMsg & e.ToString  
  31.             HttpContext.Current.Response.Write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")  
  32.         End Try  
  33.  
  34.     End Sub  
  35.  
  36.     Private Sub myMoveFile(ByVal pathName As String, ByVal target As String)  '移动文件夹  
  37.         Try  
  38.             File.Move(pathName, target)  
  39.         Catch e As Exception  
  40.             myErrMsg = myErrMsg & "从" & pathName & "移动文件到" & target & "的时候出现一个意外的错误."  
  41.             myErrMsg = myErrMsg & e.ToString  
  42.             HttpContext.Current.Response.Write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")  
  43.         End Try  
  44.     End Sub  
  45.  
  46.     Private Sub myCopyFile(ByVal fsource As String, ByVal fdestination As String)  
  47.         Try  
  48.             File.Copy(fsource, fdestination, False)  
  49.         Catch e As Exception  
  50.             myErrMsg = myErrMsg & "从" & fsource & "复制文件到" & fdestination & "的时候出现一个意外的错误."  
  51.             myErrMsg = myErrMsg & e.ToString  
  52.             HttpContext.Current.Response.Write("程序遇到一个意外的错误,详细情况请查看日志文件!<br>")  
  53.         End Try  
  54.     End Sub  
标签:

相关文章

热门资讯

玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分 2019-06-21
华为nova5pro和p30pro哪个好 华为nova5pro和华为p30pro对比详情
华为nova5pro和p30pro哪个好 华为nova5pro和华为p30pro对比详情 2019-06-22
男生常说24816是什么意思?女生说13579是什么意思?
男生常说24816是什么意思?女生说13579是什么意思? 2019-09-17
抖音撒撒累累是什么歌 撒撒累累张艺兴歌曲名字
抖音撒撒累累是什么歌 撒撒累累张艺兴歌曲名字 2019-06-05
超A是什么意思 你好a表达的是什么
超A是什么意思 你好a表达的是什么 2019-06-06
返回顶部