大小!" Return False End If Else ErrMsg = "对不起,只允许上传以下格式的文件" & LocAllowExtFile & "!" Return False End If End If End If Else ErrMsg = "上传目录未设置" Return False End If Return True End Function
''''----------------------------------------------------------------------------------------- ''''功能说明:根据日期和时间得到一个不重复的随机数文件名 ''''----------------------------------------------------------------------------------------- Public Function GetRandomFileName(ByVal strFileName As String, ByVal strExtName As String) As String
Dim tempFileName As String Dim Ext As String tempFileName = CStr(Now()) tempFileName = Replace(tempFileName, "-", "") tempFileName = Replace(tempFileName, ":", "") tempFileName = Replace(tempFileName, " ", "") tempFileName = tempFileName & GetRandomNumber(1, 1000) GetRandomFileName = tempFileName & strExtName End Function ''''---------------------------------------------------------------------------------------- ''''功能说明:获取指定上下限内的随机数 ''''----------------------------------------------------------------------------------------- Public Function GetRandomNumber(Optional ByVal Low As Integer = 1, Optional ByVal High As Integer = 100) As Integer Dim oRandom As System.Random oRandom = New System.Random(CType(System.DateTime.Now.Ticks Mod System.Int32.MaxValue, Integer)) Return oRandom.Next(Low, High + 1) End Function ''''------------------------------------------------------------------------------------ ''''功能说明:根据文件名,得到扩展名 ''''------------------------------------------------------------------------------------ Public Function GetExtName(ByVal strFileName As String) As String Return Right(strFileName, InStr(StrReverse(strFileName), ".")) End Function End Class
上一页 [1] [2] |