Urgent (but simple) FileSystemObject Question

Dim m_fso As FileSystemObject
Dim CFile As File, NFile As File, CFileStr As String, NFileStr As String, IFileindex As Long, CopyStatus As Long

Set m_fso = New FileSystemObject

''''''''
' I have 2 list boxes with 3000 filenames and paths in each, dont worry about the finer details of it!
''''''''
CFileStr = LstCFileList.List(IFileindex)
NFileList = LstNFileList.List(IFileindex)

If m_fso.FileExists(CFileStr) Then
   Set CFile = m_fso.GetFile(CFileStr)
   Set NFile = m_fso.GetFile(NFileStr)
           If CFile.Size <> NFile.Size Then
                CopyStatus = 1
            End If
'''''
' More comparissons between NFile and CFile, if an inconsistency is found, copystatus is also set to 1
'''''  
    If CopyStatus = 1 Then
        m_fso.CopyFile NFile, CFile, True
End If

-----------------------------------------------------

The Files Wont copy and I'm not sure of the correct syntax.

PLS PLS PLS correct my code.  If you need any more code snippets, let me know.


LVL 5
NAORCAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Mark_FreeSoftwareConnect With a Mentor Commented:

you better try this one, because when a file is not found, one of the objects is empty and the file isnt copied

If CopyStatus = 1 Then
        m_fso.CopyFile NFileList, CFileStr, True
End If
0
 
NAORCAuthor Commented:
*by the way, this is all part of a huge "For Next" loop that will incriment iFileIndex and rerun this script until all the files have been checked
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
If CopyStatus = 1 Then
        m_fso.CopyFile NFile.Path, CFile.path, True
End If
0
 
NAORCAuthor Commented:
You Guys are a lazy programmers dream...

Thanks y'all
0
 
Mark_FreeSoftwareCommented:

and you are a lazy expert's dream:
not too difficult questions, and much points!




thanks for the points, and good luck with your app!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.