Results 1 to 2 of 2

Thread: VB Snippet - FSO Examples

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    VB Snippet - FSO Examples

    VB Code:
    1. ' CHECKS FOR THE EXISTANCE OF A FILE
    2.  
    3. Function FILEEXISTS(ByVal lsFilename As String) As Boolean
    4.    
    5.     On Error Resume Next
    6.    
    7.     Dim FSO As New Scripting.FileSystemObject
    8.    
    9.     FILEEXISTS = FSO.FILEEXISTS(lsFilename)
    10.    
    11.     Set FSO = Nothing
    12.  
    13. End Function
    14.  
    15. ' CHECKS FOR THE EXISTANCE OF A FOLDER
    16.  
    17. Function FOLDEREXISTS(ByVal lsFilename As String) As Boolean
    18.    
    19.     On Error Resume Next
    20.    
    21.     Dim FSO As New Scripting.FileSystemObject
    22.    
    23.     FOLDEREXISTS = FSO.FOLDEREXISTS(lsFilename)
    24.    
    25.     Set FSO = Nothing
    26.  
    27. End Function
    28.  
    29. ' COPIES FILES
    30.  
    31. Function COPYFILE(ByVal lsSource As String, ByVal lsDestination As String, _
    32. Optional ByVal lbOverWriteFiles As Boolean) As Boolean
    33.    
    34.     On Error GoTo CopyFile_EH
    35.    
    36.     Dim FSO As New Scripting.FileSystemObject
    37.    
    38.     Dim lbOverwrite As Boolean
    39.    
    40.     If FSO.FILEEXISTS(lsSource) Then
    41.        
    42.         If IsMissing(lbOverWriteFiles) Then
    43.            
    44.             lbOverwrite = False
    45.        
    46.         Else
    47.            
    48.             lbOverwrite = lbOverWriteFiles
    49.        
    50.         End If
    51.        
    52.         FSO.COPYFILE lsSource, lsDestination
    53.        
    54.         COPYFILE = True
    55.    
    56.     Else
    57.        
    58.         COPYFILE = False
    59.    
    60.     End If
    61.    
    62. CopyFile_Exit:
    63.    
    64.     Set FSO = Nothing
    65.    
    66.     Exit Function
    67.    
    68. CopyFile_EH:
    69.    
    70.     COPYFILE = False
    71.    
    72.     Resume CopyFile_Exit
    73.  
    74. End Function
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    More

    VB Code:
    1. '*******************************************************************************
    2. ' FIXFOLDER (SUB)
    3. '
    4. ' DESCRIPTION:
    5. ' SET ANY SENT FOLDERS TO HIDDEN
    6.  '***************************************************
    7. Sub FIXFOLDER(FDR As String)
    8.    
    9.     Dim FSO As New Scripting.FileSystemObject
    10.    
    11.     Dim F As Folder
    12.    
    13.     Set F = FSO.GetFolder(FDR)
    14.    
    15.     F.Attributes = Hidden
    16.    
    17.     Set F = Nothing
    18.    
    19.     Set FSO = Nothing
    20.    
    21. End Sub
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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