[Help]Delete Copies

Posts 1–11 of 11 · Page 1 of 1
[Help]Delete Copies
Is there any way to make a program that can delete copies of the same file in a single folder and delete numbers before the file pm me the code if it is possible thanks.
I don't really understand your question. Please explain it with better English. Thank You.
You want to delete an application file which is running trying to delete itself?

You can't delete something that is in use. And don't ask for code... What about if you try urself first?

If you are actually trying to delete something on the folder, I advice you to have a look on System.IO Library, as i am not spoonfeeding you.
I think he simply wants to delete duplicate files in the same folder. If that's what you're aiming at, do what Brinuz said and consult the System.IO namespace (HINT: to see if the files have identical content, check the bytes)

As for removing a number from the beginning of a file...again the System.IO namespace is your best bet, or perhaps My.Computer.FileSystem, either way all you need to do is grab the current file name, use string manip to make it suit your needs, then rename the file to your new name.
Check in startup if a similar file exists, if so delete it....

Tips:

Application.executeablepath
io.file.delete
io.file.exists
using FileInfo, get all files in folder. MD5/SHA each file, and compare their hashes. If they are the same, delete on of them.
You can compare 2 files to know if they are identical:

Code:
If Dir(File1) = "" Then Exit Function
If Dir(File2) = "" Then Exit Function

Dim lLen1 As Long, lLen2 As Long
Dim iFileNum1 As Integer
Dim iFileNum2 As Integer
Dim bytArr1() As Byte, bytArr2() As Byte
Dim lCtr As Long, lStart As Long
Dim bAns As Boolean

lLen1 = FileLen(File1)
lLen2 = FileLen(File2)
If lLen1 <> lLen2 Then
    Exit Function
ElseIf StringentCheck = False Then
        AreTheyTheSame = True
        Exit Function
Else
    iFileNum1 = FreeFile
    Open File1 For Binary Access Read As #iFileNum1
    iFileNum2 = FreeFile
    Open File2 For Binary Access Read As #iFileNum2

    'put contents of both into byte Array
    bytArr1() = InputB(LOF(iFileNum1), #iFileNum1)
    bytArr2() = InputB(LOF(iFileNum2), #iFileNum2)
    lLen1 = UBound(bytArr1)
    lStart = LBound(bytArr1)
    
    bAns = True
    For lCtr = lStart To lLen1
        If bytArr1(lCtr) <> bytArr2(lCtr) Then
            bAns = False
            Exit For
        End If
            
    Next
    AreTheyTheSame = bAns
       
End If
 
ErrorHandler:
If iFileNum1 > 0 Then Close #iFileNum1
If iFileNum2 > 0 Then Close #iFileNum2
End Function
If they are, just delete one...
Quote Originally Posted by SmartAlley View Post
You can compare 2 files to know if they are identical:

Code:
If Dir(File1) = "" Then Exit Function
If Dir(File2) = "" Then Exit Function

Dim lLen1 As Long, lLen2 As Long
Dim iFileNum1 As Integer
Dim iFileNum2 As Integer
Dim bytArr1() As Byte, bytArr2() As Byte
Dim lCtr As Long, lStart As Long
Dim bAns As Boolean

lLen1 = FileLen(File1)
lLen2 = FileLen(File2)
If lLen1 <> lLen2 Then
    Exit Function
ElseIf StringentCheck = False Then
        AreTheyTheSame = True
        Exit Function
Else
    iFileNum1 = FreeFile
    Open File1 For Binary Access Read As #iFileNum1
    iFileNum2 = FreeFile
    Open File2 For Binary Access Read As #iFileNum2

    'put contents of both into byte Array
    bytArr1() = InputB(LOF(iFileNum1), #iFileNum1)
    bytArr2() = InputB(LOF(iFileNum2), #iFileNum2)
    lLen1 = UBound(bytArr1)
    lStart = LBound(bytArr1)
    
    bAns = True
    For lCtr = lStart To lLen1
        If bytArr1(lCtr) <> bytArr2(lCtr) Then
            bAns = False
            Exit For
        End If
            
    Next
    AreTheyTheSame = bAns
       
End If
 
ErrorHandler:
If iFileNum1 > 0 Then Close #iFileNum1
If iFileNum2 > 0 Then Close #iFileNum2
End Function
If they are, just delete one...
Wanna give credits for source?

And it needn't be that complex, as freedom said, get the md5 hashes of the two files. If they are the same, delete one.
Quote Originally Posted by Jason View Post


Wanna give credits for source?

And it needn't be that complex, as freedom said, get the md5 hashes of the two files. If they are the same, delete one.
Well, obviously is not mine -_- and I didnt said it was
I didn't released anything, Im not taking credits of this
But also there's no way you can find out if this is mine or not in case
Im a dumbass and say is mine

Credits?
Google who help me to find it...
I wont say website since I wont advertise
Quote Originally Posted by SmartAlley View Post


Well, obviously is not mine -_- and I didnt said it was
I didn't released anything, Im not taking credits of this
But also there's no way you can find out if this is mine or not in case
Im a dumbass and say is mine

Credits?
Google who help me to find it...
I wont say website since I wont advertise
I know it's not yours because you made a thread about a week or two ago saying you wanted to start learning.
Quote Originally Posted by Jason View Post


I know it's not yours because you made a thread about a week or two ago saying you wanted to start learning.
smart boy

Soon I will release something, and I will give credits even if I take some tips of any coder out there
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us