'原來用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