Solved

How to copy multiple files with same extension in .NET

Posted on 2003-10-27
3
929 Views
Last Modified: 2007-12-19
Hello,

In VB 6, I was able to copy all files from a folder with a .txt extension to a backup folder.  I used CopyFile and the *.txt to do it.  I do not believe you can use the wildcard symbol with the System.IO.File Copy member.

I'm sure there is a simple way to do this, but I have not discovered it.

smsak.
0
Comment
Question by:smsak
3 Comments
 
LVL 4

Accepted Solution

by:
NetPointer earned 50 total points
Comment Utility
I use GetFiles method of Directory Object with wildcard, and loop thru it.

Regards.
NetPointer
0
 
LVL 28

Assisted Solution

by:iboutchkine
iboutchkine earned 50 total points
Comment Utility
You can use wildcards

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim FilePath As String = "C:\temp\"

        Dim rFileName As String = ""
        Do
            If rFileName = "" Then
                'Call Dir with Path info
                rFileName = Dir(FilePath & "*.txt")
            Else
                rFileName = Dir()
            End If
            If rFileName = "" Then Exit Do
            File.Copy(FilePath & rFileName, DestinationPath)
        Loop

    End Sub
End Class
0
 

Author Comment

by:smsak
Comment Utility
I thank you both for your input.

smsak.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now