Solved

How to copy multiple files with same extension in .NET

Posted on 2003-10-27
3
945 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
[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
3 Comments
 
LVL 4

Accepted Solution

by:
NetPointer earned 50 total points
ID: 9630125
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
ID: 9633938
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
ID: 9634065
I thank you both for your input.

smsak.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 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