Results 1 to 11 of 11

Hybrid View

  1. #1
    HalfBajan's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    5,826
    Reputation
    1015
    Thanks
    1,112

    [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.

  2. #2
    Born2Amuse's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Sydney, Australia
    Posts
    36
    Reputation
    10
    Thanks
    9
    My Mood
    Innocent
    I don't really understand your question. Please explain it with better English. Thank You.

  3. #3
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    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.
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  4. #4
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    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.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  5. #5
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    Check in startup if a similar file exists, if so delete it....

    Tips:

    Application.executeablepath
    io.file.delete
    io.file.exists



  6. #6
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    using FileInfo, get all files in folder. MD5/SHA each file, and compare their hashes. If they are the same, delete on of them.

  7. The Following User Says Thank You to freedompeace For This Useful Post:

    Qizzle15401 (01-26-2011)

  8. #7
    SmartAlley's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    CA General Section
    Posts
    14,370
    Reputation
    577
    Thanks
    1,661
    My Mood
    Hot
    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...

  9. #8
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    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 Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  10. #9
    SmartAlley's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    CA General Section
    Posts
    14,370
    Reputation
    577
    Thanks
    1,661
    My Mood
    Hot
    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

  11. #10
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    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 Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  12. #11
    SmartAlley's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    CA General Section
    Posts
    14,370
    Reputation
    577
    Thanks
    1,661
    My Mood
    Hot
    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