Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
How to copy only one month files in vb.net
Supraja
Sep 27 2016 10:04 PM
309
Reply
I am trying to copy files from one folder to another folder, i has to get only one month files for example the files should copy only from 27/8/2016 to till date if i run now, i coded for this but its not working its copying January files also can anyone suggest what need to change.
Public Sub FileCopy(src As String, dest As String)
Dim lastOneMonth As DateTime = DateTime.Now.AddMonths(-1)
Dim DateModified = File.GetCreationTime("D:\Working Files\Commercial Team\Retail\Billing\Invoices\2016")
If DateModified >= lastOneMonth Then
Dim totalFiles As Integer = 0
Dim filePath As String = Path.GetDirectoryName(file__1)
Dim fileName As String = Path.GetFileNameWithoutExtension(file__1.ToString())
If fileName.Contains("_I-") OrElse fileName.Contains("_IS") OrElse fileName.Contains("_C-") AndAlso fileName.Length = 10 Then
Dim newFullName As String = dest & "\" & fileName & ".pdf"
File.Copy(file__1.ToString(), newFullName, True)
totalFiles += 1
End If
Next
Dim tFiles As Integer = totalFiles
Catch ex As IOException
End Try
end if
End Sub
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
In .net Property of get/set how to call inside function
FTP upload file The requested FTP command