50,230 Members
3 added today
250,678 Resources
38 added today

All Devdex   All XMLdex   Current Category
XMLdex > Forums & Newsgroups > Newsgroups > microsoft.public.dotnet.xml Add this category to My Favorites

View Message Thread  (23 replies)

Results 1 - 10 of 24 Next Page »

VB copy files from one folder to other Add this thread to My Favorites
From: K
Date Posted: 6/11/2010 2:20:00 AM

Hi all, I am using Visual Basic 2008.  I am working on code with which
I can copy specified extention files from one folder to other. I need
two codes, one which can copy files of specified extention only from
top main folder and two which can copy files of specified extention
from top main folder as well as from all the subfolder which exist in
that top main folder. In these both codes I also need to have
progress bar code to show user the progress. I am struggling on this
and so far i came up with code (see below) which only copies files
from top main folder and i am getting error on line
"ProgressBar1.Value = (n / Fldrfl.Count) * 100".  I'll be very
greatful if any friend can help me on this.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim FldrNm As String
Dim Fso As Object
Dim Fldr As Object
Dim Fldrfl As Object
Dim n As Long

FldrNm = TextBox1.Text
Fso = CreateObject("Scripting.FileSystemObject")
Fldr = Fso.GetFolder(FldrNm)
For Each Fldrfl In Fldr.Files
If Microsoft.VisualBasic.Right(Fldrfl.Name,
Microsoft.VisualBasic.Len(Fldrfl.Name) -
Microsoft.VisualBasic.InStrRev(Fldrfl.Name, ".")) = TextBox2.Text Then
Fldrfl.Copy(TextBox3.Text & "\" & Fldrfl.Name)
n = n + 1
ProgressBar1.Value = (n / Fldrfl.Count) * 100
Application.DoEvents()
End If
Next

Fldrfl = Nothing
Fldr = Nothing
Fso = Nothing

MsgBox("Files have been copied successful!", MsgBoxStyle.Information,
"Done!")
End If
End Sub

VB copy files from one folder to other
From: K
Date Posted: 6/11/2010 2:21:00 AM

Hi all, I am using Visual Basic 2008.  I am working on code with which
I can copy specified extention files from one folder to other. I need
two codes, one which can copy files of specified extention only from
top main folder and two which can copy files of specified extention
from top main folder as well as from all the subfolder which exist in
that top main folder. In these both codes I also need to have
progress bar code to show user the progress. I am struggling on this
and so far i came up with code (see below) which only copies files
from top main folder and i am getting error on line
"ProgressBar1.Value = (n / Fldrfl.Count) * 100".  I'll be very
greatful if any friend can help me on this.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim FldrNm As String
Dim Fso As Object
Dim Fldr As Object
Dim Fldrfl As Object
Dim n As Long

FldrNm = TextBox1.Text
Fso = CreateObject("Scripting.FileSystemObject")
Fldr = Fso.GetFolder(FldrNm)
For Each Fldrfl In Fldr.Files
If Microsoft.VisualBasic.Right(Fldrfl.Name,
Microsoft.VisualBasic.Len(Fldrfl.Name) -
Microsoft.VisualBasic.InStrRev(Fldrfl.Name, ".")) = TextBox2.Text Then
Fldrfl.Copy(TextBox3.Text & "\" & Fldrfl.Name)
n = n + 1
ProgressBar1.Value = (n / Fldrfl.Count) * 100
Application.DoEvents()
End If
Next

Fldrfl = Nothing
Fldr = Nothing
Fso = Nothing

MsgBox("Files have been copied successful!", MsgBoxStyle.Information,
"Done!")
End If
End Sub

VB copy files from one folder to other
From: K
Date Posted: 6/11/2010 2:22:00 AM

Hi all, I am using Visual Basic 2008.  I am working on code with which
I can copy specified extention files from one folder to other. I need
two codes, one which can copy files of specified extention only from
top main folder and two which can copy files of specified extention
from top main folder as well as from all the subfolder which exist in
that top main folder. In these both codes I also need to have
progress bar code to show user the progress. I am struggling on this
and so far i came up with code (see below) which only copies files
from top main folder and i am getting error on line
"ProgressBar1.Value = (n / Fldrfl.Count) * 100".  I'll be very
greatful if any friend can help me on this.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim FldrNm As String
Dim Fso As Object
Dim Fldr As Object
Dim Fldrfl As Object
Dim n As Long

FldrNm = TextBox1.Text
Fso = CreateObject("Scripting.FileSystemObject")
Fldr = Fso.GetFolder(FldrNm)
For Each Fldrfl In Fldr.Files
If Microsoft.VisualBasic.Right(Fldrfl.Name,
Microsoft.VisualBasic.Len(Fldrfl.Name) -
Microsoft.VisualBasic.InStrRev(Fldrfl.Name, ".")) = TextBox2.Text Then
Fldrfl.Copy(TextBox3.Text & "\" & Fldrfl.Name)
n = n + 1
ProgressBar1.Value = (n / Fldrfl.Count) * 100
Application.DoEvents()
End If
Next

Fldrfl = Nothing
Fldr = Nothing
Fso = Nothing

MsgBox("Files have been copied successful!", MsgBoxStyle.Information,
"Done!")
End If
End Sub

Re: VB copy files from one folder to other
From: Andrew Morton
Date Posted: 6/11/2010 2:36:00 AM

K wrote:
> Hi all, I am using Visual Basic 2008.  I am working on code with which
> I can copy specified extention files from one folder to other. I need
> two codes, one which can copy files of specified extention only from
> top main folder and two which can copy files of specified extention
> from top main folder as well as from all the subfolder which exist in
> that top main folder. In these both codes I also need to have
> progress bar code to show user the progress. I am struggling on this
> and so far i came up with code (see below) which only copies files
> from top main folder and i am getting error on line
> "ProgressBar1.Value = (n / Fldrfl.Count) * 100".  I'll be very
> greatful if any friend can help me on this.

Go on, give us a chance - what's the error message?

However...

> Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button3.Click
> Dim FldrNm As String
> Dim Fso As Object
> Dim Fldr As Object
> Dim Fldrfl As Object
> Dim n As Long

Why Long rather than Integer?

> FldrNm = TextBox1.Text
> Fso = CreateObject("Scripting.FileSystemObject")

I'm pretty sure you'd be better off using System.IO for this sort of thing.

> Fldr = Fso.GetFolder(FldrNm)
> For Each Fldrfl In Fldr.Files
> If Microsoft.VisualBasic.Right(Fldrfl.Name,
> Microsoft.VisualBasic.Len(Fldrfl.Name) -
> Microsoft.VisualBasic.InStrRev(Fldrfl.Name, ".")) = TextBox2.Text Then

See System.IO.Path.GetExtension()

> Fldrfl.Copy(TextBox3.Text & "\" & Fldrfl.Name)
> n = n + 1
> ProgressBar1.Value = (n / Fldrfl.Count) * 100

You probably meant Fldr.Count

> Application.DoEvents()
> End If
> Next
>
> Fldrfl = Nothing
> Fldr = Nothing
> Fso = Nothing

In general, it's best not to set things to Nothing because it gets in the
way of garbage collection.

> MsgBox("Files have been copied successful!", MsgBoxStyle.Information,
> "Done!")
> End If
> End Sub

--
Andrew

Re: VB copy files from one folder to other
From: Andrew Morton
Date Posted: 6/11/2010 2:37:00 AM

K wrote:
> Hi all, I am using Visual Basic 2008.  I am working on code with which
> I can copy specified extention files from one folder to other. I need
> two codes, one which can copy files of specified extention only from
> top main folder and two which can copy files of specified extention
> from top main folder as well as from all the subfolder which exist in
> that top main folder. In these both codes I also need to have
> progress bar code to show user the progress. I am struggling on this
> and so far i came up with code (see below) which only copies files
> from top main folder and i am getting error on line
> "ProgressBar1.Value = (n / Fldrfl.Count) * 100".  I'll be very
> greatful if any friend can help me on this.

Go on, give us a chance - what's the error message?

However...

> Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button3.Click
> Dim FldrNm As String
> Dim Fso As Object
> Dim Fldr As Object
> Dim Fldrfl As Object
> Dim n As Long

Why Long rather than Integer?

> FldrNm = TextBox1.Text
> Fso = CreateObject("Scripting.FileSystemObject")

I'm pretty sure you'd be better off using System.IO for this sort of thing.

> Fldr = Fso.GetFolder(FldrNm)
> For Each Fldrfl In Fldr.Files
> If Microsoft.VisualBasic.Right(Fldrfl.Name,
> Microsoft.VisualBasic.Len(Fldrfl.Name) -
> Microsoft.VisualBasic.InStrRev(Fldrfl.Name, ".")) = TextBox2.Text Then

See System.IO.Path.GetExtension()

> Fldrfl.Copy(TextBox3.Text & "\" & Fldrfl.Name)
> n = n + 1
> ProgressBar1.Value = (n / Fldrfl.Count) * 100

You probably meant Fldr.Count

> Application.DoEvents()
> End If
> Next
>
> Fldrfl = Nothing
> Fldr = Nothing
> Fso = Nothing

In general, it's best not to set things to Nothing because it gets in the
way of garbage collection.

> MsgBox("Files have been copied successful!", MsgBoxStyle.Information,
> "Done!")
> End If
> End Sub

--
Andrew

Re: VB copy files from one folder to other
From: Andrew Morton
Date Posted: 6/11/2010 2:38:00 AM

K wrote:
> Hi all, I am using Visual Basic 2008.  I am working on code with which
> I can copy specified extention files from one folder to other. I need
> two codes, one which can copy files of specified extention only from
> top main folder and two which can copy files of specified extention
> from top main folder as well as from all the subfolder which exist in
> that top main folder. In these both codes I also need to have
> progress bar code to show user the progress. I am struggling on this
> and so far i came up with code (see below) which only copies files
> from top main folder and i am getting error on line
> "ProgressBar1.Value = (n / Fldrfl.Count) * 100".  I'll be very
> greatful if any friend can help me on this.

Go on, give us a chance - what's the error message?

However...

> Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button3.Click
> Dim FldrNm As String
> Dim Fso As Object
> Dim Fldr As Object
> Dim Fldrfl As Object
> Dim n As Long

Why Long rather than Integer?

> FldrNm = TextBox1.Text
> Fso = CreateObject("Scripting.FileSystemObject")

I'm pretty sure you'd be better off using System.IO for this sort of thing.

> Fldr = Fso.GetFolder(FldrNm)
> For Each Fldrfl In Fldr.Files
> If Microsoft.VisualBasic.Right(Fldrfl.Name,
> Microsoft.VisualBasic.Len(Fldrfl.Name) -
> Microsoft.VisualBasic.InStrRev(Fldrfl.Name, ".")) = TextBox2.Text Then

See System.IO.Path.GetExtension()

> Fldrfl.Copy(TextBox3.Text & "\" & Fldrfl.Name)
> n = n + 1
> ProgressBar1.Value = (n / Fldrfl.Count) * 100

You probably meant Fldr.Count

> Application.DoEvents()
> End If
> Next
>
> Fldrfl = Nothing
> Fldr = Nothing
> Fso = Nothing

In general, it's best not to set things to Nothing because it gets in the
way of garbage collection.

> MsgBox("Files have been copied successful!", MsgBoxStyle.Information,
> "Done!")
> End If
> End Sub

--
Andrew

Re: VB copy files from one folder to other
From: K
Date Posted: 6/11/2010 3:02:00 AM

Hi Andrew, Thanks for replying. Is it possible for you to write me a
code which can achive what i need.

Re: VB copy files from one folder to other
From: K
Date Posted: 6/11/2010 3:03:00 AM

Hi Andrew, Thanks for replying. Is it possible for you to write me a
code which can achive what i need.

Re: VB copy files from one folder to other
From: K
Date Posted: 6/11/2010 3:04:00 AM

Hi Andrew, Thanks for replying. Is it possible for you to write me a
code which can achive what i need.

Re: VB copy files from one folder to other
From: Andrew Morton
Date Posted: 6/11/2010 3:17:00 AM

K wrote:
> Hi Andrew, Thanks for replying. Is it possible for you to write me a
> code which can achive what i need.

Well, I'm not very busy right now... tell us exactly what the code should
do - the names of your TextBoxes don't help to explain.

--
Andrew

Results 1 - 10 of 24 Next Page »

 

Would you like to track this thread?

By adding this News Thread to your Favorites Area you can refer to it later with just a click of the mouse. Also you can optionally be notified instantly whenever there are any replies posted to this Thread. To add this Thread to your Favorites Area just click on the red arrow next to the subject of the thread above Add this thread to My Favorites.



ASP.NET Web Hosting
- FREE Setup & Domain
- First month FREE
100% IIS6 / Server 2003

ASP ArticlesThis category has been added to your weekly newsletter
ASP Web Sites
ADSI & WSH BooksThis category has been added to your weekly newsletter
FREE ComponentsThis category has been added to your weekly newsletter
ASP EventsThis category has been added to your weekly newsletter
ASP HeadlinesThis category has been added to your weekly newsletter

CSharp ArticlesThis category has been added to your weekly newsletter
C# Web SitesThis category has been added to your weekly newsletter

SQL ArticlesThis category has been added to your weekly newsletter
SQL Events
SQL HeadlinesThis category has been added to your weekly newsletter
SQL Jobs

Jobs in CaliforniaThis category has been added to your weekly newsletter

XML ArticlesThis category has been added to your weekly newsletter
XML BooksThis category has been added to your weekly newsletter
XML Web Sites
XML Tutorials

free asp host

"Alex Homer"This search has been added to your weekly newsletter

Edit My Favorites Edit Profile & Favorites

 

 

 

 

 




Developersdex Home | ASP | C# | SQL | VB | XML | Gurus
Add Your Link | Add Your Code | FAQ | Advertise | Link To Us | Contact Us |
Copyright © 2010 Developersdex™. All rights reserved.