VB icon

Basic File Class

Email
Submitted on: 1/25/2015 6:22:00 AM
By: poop_4_brains (from psc cd)  
Level: Beginner
User Rating: By 2 Users
Compatibility: VB 6.0
Views: 706
 
     pretty basic file class.... you can get the filename, path, drive, and extension of a file (string)... and plus you can copy files, delete files, create blanks for files (useful for prop files), and wipe files... havent tested the wipe but from what i see it should work... please vote and PLEASE COMMENT!
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Basic File Class
' Description:pretty basic file class.... you can get the filename, path, drive, and extension of a file (string)... and plus you can copy files, delete files, create blanks for files (useful for prop files), and wipe files... havent tested the wipe but from what i see it should work... please vote and PLEASE COMMENT!
' By: poop_4_brains (from psc cd)
'**************************************

Function GetFilename(path As String)
GetFilename = Mid(path, InStrRev(path, "/") + 1)
End Function
Function GetFilepath(path As String)
GetFilepath = Mid(path, 1, InStrRev(path, "/"))
End Function
Function GetFileExt(path As String)
GetFileExt = Mid(path, InStrRev(path, "."))
End Function
Function GetFileDrive(path As String)
GetFileDrive = Mid(path, 1, InStr(1, path, "/"))
End Function
Function CreateBlank(path As String)
Dim Free As Integer
Free = FreeFile
Open path For Binary As Free
Close Free
End Function
Function FileExist(path As String)
On Error GoTo Oop
Dim Free As Integer
Free = FreeFile
FileExist = True
Open path For Input As Free
Close Free
Exit Function
Oop:
FileExist = False
End Function
Function CopyFile(oldpath As String, newpath As String)
FileSystem.FileCopy oldpath, newpath
End Function
Function DeleteFile(path As String)
Kill path
End Function
Private Function Rand(L, U) As Long
Dim I As Long
For I = L To U
If Int(Rnd * (U - L)) = Int(Rnd * (U - L + 1)) Then Rand = I: Exit Function
Next I
End Function
Private Function ScrambleArray(ar())
Dim I As Long
For I = LBound(ar()) To UBound(ar())
ar(I) = ar(Rand(LBound(ar()), UBound(ar())))
Next I
End Function
Function WipeFile(path As String)
Dim I As Long, B() As Byte, Free As Integer
Free = FreeFile
Open path For Binary As FreeFile
For I = 0 To 500
Get #1, , B()
ScrambleArray B()
Put #1, , B()
Next I
Close FreeFile
End Function


Other 35 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.