结合FSO操作和Aspjpeg组件写的Class(2)
File_Path=""
File_AllowType="gif|jpg|png|txt"
File_NewFolder_Path=""
File_NewName=""
File_CoverIf=1
File_deleteIf=0
End Sub
Private Sub Class_Terminate()
Err.Clear
Set FSO=Nothing
End Sub
Public Function UpDir(ByVal D)
If Len(D) = 0 then
UpDir=""
Else
UpDir=Left(D,InStrRev(D,"\")-1)
End If
End Function
Public Function GetPrefixName(ByVal D)
If Len(D) = 0 then
GetPrefixName=""
Else
FileName=GetFileName(D)
GetPrefixName=Left(FileName,InStrRev(FileName,".")-1)
End If
End Function
Public Function GetFileName(name)
FileName=Split(name,"\")
GetFileName=FileName(Ubound(FileName))
End Function
Public Function GetExtensionName(name)
FileName=Split(name,".")
GetExtensionName=FileName(Ubound(FileName))
End Function
Public Function FileIs(Path)
If fso.FileExists(Path) then
FileIs=true
Else
FileIs=false
End If
End Function
Public Function FileOpen(Path,NewFile,ReadAction,LineCount)
If FileIs(Path)=False then
If NewFile<>1 then
FileOpen=False
ElseIf FolderIs(UpDir(Path))=False then
FileOpen=False
Exit Function
Else
fso.OpenTextFile Path,1,True
FileOpen=""
End If
Exit Function
End If
Set FileOption=fso.GetFile(Path)
If FileOption.size=0 then
Set FileOption=Nothing
FileOpen=""
Exit Function
End If
Set FileOption=Nothing
Set FileText=fso.OpenTextFile(Path,1)
If IsNumeric(ReadAction) then
FileOpen=FileText.Read(ReadAction)
ElseIf Ucase(ReadAction)="ALL" then
FileOpen=FileText.ReadAll()
ElseIf Ucase(ReadAction)="LINE" then
If Not(IsNumeric(LineCount)) or LineCount=0 then
FileOpen=False
Set FileText=Nothing
Exit Function
Else
i=0
Do While Not FileText.AtEndOfStream
FileOpen=FileOpen&FileText.ReadLine
i=i+1
If i=LineCount then Exit Do
Loop
End If
End If
Set FileText=Nothing
End Function
Public Function FileWrite(Path,WriteStr,NewFile)
If FolderIs(UpDir(Path))=False then
FileWrite=False
Exit Function
ElseIf FileIs(Path)=False and NewFile<>1 then
FileWrite=False
Exit Function
End If
Set FileText=fso.OpenTextFile(Path,2,True)
FileText.Write WriteStr
Set FileText=Nothing
FileWrite=True
End Function
Public Function FolderIs(Path)
If fso.FolderExists(Path) then
FolderIs=true
Else
FolderIs=false
End If
End Function
内容版权声明:除非注明,否则皆为本站原创文章。