Results 1 to 7 of 7

Thread: [RESOLVED] Delete a certian file format in a folder.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    76

    Resolved [RESOLVED] Delete a certian file format in a folder.

    .....
    Last edited by G3rmanpride21; Jan 28th, 2016 at 06:01 PM.

  2. #2
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Delete a certian file format in a folder.

    That's very possible. I don't know the exact code but you use something like For Each ffile as File in Directory.GetAllFiles and then an if statement for each file to see if the end has the same extension as dem1, then you use .Kill to delete it. Someone will probably post some code for you.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    76

    Re: Delete a certian file format in a folder.

    .....
    Last edited by G3rmanpride21; Jan 28th, 2016 at 06:01 PM.

  4. #4
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Delete a certian file format in a folder.

    Try this

    Code:
            Dim Dir As String = "C:\Directory"
            Dim fileList As New List(Of String)
            fileList.AddRange(My.Computer.FileSystem.GetFiles(Dir))
    
            For x As Integer = 0 To fileList.Count - 1
                Dim theFile As String = fileList.Item(x)
    
                If My.Computer.FileSystem.GetFileInfo(theFile).Extension = ".dem1" Then
                    My.Computer.FileSystem.DeleteFile(Dir & "\" & theFile)
                End If
            Next
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    76

    Re: Delete a certian file format in a folder.

    .....
    Last edited by G3rmanpride21; Jan 28th, 2016 at 06:02 PM.

  6. #6
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Delete a certian file format in a folder.

    Sorry, take out Dir & "\" &.
    Code:
            Dim Dir As String = "C:\Directory"
            Dim fileList As New List(Of String)
            fileList.AddRange(My.Computer.FileSystem.GetFiles(Dir))
    
            For x As Integer = 0 To fileList.Count - 1
                Dim theFile As String = fileList.Item(x)
    
                If My.Computer.FileSystem.GetFileInfo(theFile).Extension = ".dem1" Then
                    My.Computer.FileSystem.DeleteFile(theFile)
                End If
            Next
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    76

    Re: [RESOLVED] Delete a certian file format in a folder.

    .....
    Last edited by G3rmanpride21; Jan 28th, 2016 at 06:02 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width