Link to home
Start Free TrialLog in
Avatar of AlHal2
AlHal2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

VB6 filesystem object in vb2005

Please can someone upgrade this code from VB6 to VB 2005 as the upgrade wizard fails?


Dim Mload As Folder, RepFile As File, NewFile As String, MloadDirectory As Files
Dim FSO As FileSystemObject

Private Sub form_Load()

Set FSO = New FileSystemObject

Set Mload = FSO.GetFolder("C:\temp")
Set MloadDirectory = Mload.Files
For Each RepFile In MloadDirectory
    RepFile.Delete
Next
ASKER CERTIFIED SOLUTION
Avatar of Blackninja2007
Blackninja2007

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Tomlinson
Click on Project --> Add Reference.
Switch to the "COM" Tab.
Select the "Microsoft Scripting Runtime" Entry and Click "OK".

Your converted code:
Public Class Form1
 
    Private Mload As Scripting.Folder, RepFile As Scripting.File, NewFile As String, MloadDirectory As Scripting.Files
    Private FSO As Scripting.FileSystemObject
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        FSO = New Scripting.FileSystemObject
 
        Mload = FSO.GetFolder("C:\temp")
        MloadDirectory = Mload.Files
        For Each RepFile In MloadDirectory
            RepFile.Delete()
        Next
    End Sub
 
End Class

Open in new window

Avatar of AlHal2

ASKER

That's great.  Thanks.