Solved

Copy Files that match a pattern

Posted on 2013-02-04
2
321 Views
Last Modified: 2013-02-04
I have two files that are being copied to a folder. One file name contains the word "email" and the other "ftp". I am trying to figure out how to take all the items that contan "ftp" and move them to another drive. Does anyone have a good idea how to accomplish?
0
Comment
Question by:earngreen
[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 Comments
 
LVL 27

Accepted Solution

by:
nmarun earned 500 total points
ID: 38851594
You basically want to get all the files in the folder and then for each of them, check if they match a pattern.

    Dim strFileSize As String = ""
    Dim di As New IO.DirectoryInfo("C:\temp")
    Dim aryFi As IO.FileInfo() = di.GetFiles("*.txt")
    Dim fi As IO.FileInfo

    For Each fi In aryFi
        If(fi.Name.Contains("email")) Then
           // do something
        Else If (fi.Name.Contains("ftp")) Then
           // do something else
    Next

Reference:

http://www.thescarms.com/dotnet/ListFiles.aspx

Arun
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38851601
One line of code:

Directory.GetFiles("your-directory", "*ftp*", SearchOption.AllDirectories);

Open in new window

If u dont want to sesrch in sub directories remove the last parameter
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

740 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