Solved

Urgent (but simple) FileSystemObject Question

Posted on 2006-06-28
5
164 Views
Last Modified: 2012-05-05
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.


0
Comment
Question by:NAORC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Author Comment

by:NAORC
ID: 17000136
*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
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17000139
If CopyStatus = 1 Then
        m_fso.CopyFile NFile.Path, CFile.path, True
End If
0
 
LVL 13

Accepted Solution

by:
Mark_FreeSoftware earned 500 total points
ID: 17000172

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
 
LVL 5

Author Comment

by:NAORC
ID: 17000181
You Guys are a lazy programmers dream...

Thanks y'all
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 17000202

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Advice in Xamarin 21 118
RUNRMTCMD from AS/400 13 122
VBA: Insert New column with specific format type 12 55
Access 2003, find all instances of database ODBC 3 40
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question