Fradojr88
asked on
How can I select directories with in a date range - 14 days.
I am trying to zip up multiple directories that are named in 20150716 format for every day of the year - 14 Days when the application is run. It will then take the zip file and upload it to a ftp server. I have the code done for the zipping of some other files and upload it up the ftp server. But I am having trouble coming up with the code for the Directories.
I dont want it to individual zip each directory as much as zip to the current day - 14 days.
Is this possible if so can I get a code example.
I am using Visual Basic 2013.
Thanks,
Current example of the code below
I have also tried the following.
although I was never able to get that to work as it was always saying it was not declared.
I dont want it to individual zip each directory as much as zip to the current day - 14 days.
Is this possible if so can I get a code example.
I am using Visual Basic 2013.
Thanks,
Current example of the code below
Imports System.IO.Compression ' Declaring refrences
Imports System.IO ' Declaring refrences
Imports System.Web
Imports System.Net.Mail
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim startPath1 As String = "D:\Bootdrv\AlohaQS\DATA\" ' Setting the DATA Folder For Zipping
Dim startPath2 As String = "D:\Bootdrv\AlohaQS\NEWDATA\" ' Setting the NEWDATA Folder for Zipping
Dim zipPath1 As String = "D:\Bootdrv\AlohaQS\WILL_DATA.zip" ' Nameing the Backup ZIP
Dim zipPath2 As String = "D:\Bootdrv\AlohaQS\WILL_NEWDATA.ZIP" 'Nameing the Back up ZIP
ZipFile.CreateFromDirectory(startPath1, zipPath1)
ZipFile.CreateFromDirectory(startPath2, zipPath2)
Dim myFTPaddress As String = "ftp server" ' ftp server
Dim myFTPuserName As String = "username" ' ftp username
Dim myFTPuserPassword As String = "password" 'ftp password
Dim myFiles() As String = {"D:\Bootdrv\AlohaQS\WILL_DATA.ZIP", "D:\Bootdrv\AlohaQS\WILL_NEWDATA.ZIP"} '// files for Uploading
Dim sTemp As String = Nothing '// used to extract only FileName with Extenstion.
For Each mySelectedFile As String In myFiles '// loop thru your files.
sTemp = IO.Path.GetFileName(mySelectedFile) '// get only the file name with extension from Full Path.
'// upload File to website.
My.Computer.Network.UploadFile(mySelectedFile, myFTPaddress & sTemp, myFTPuserName, myFTPuserPassword)
Next
Dim thisDate As Date
thisDate = Today
My.Computer.FileSystem.WriteAllText("D:\Bootdrv\AlohaQS\TMP\FTPBackupDebout.txt", "thisDateFTP Back Up Completed Successfully", True) 'Writes to the debout that it was successful
Me.Close()
Catch
Dim thisDate As Date
thisDate = Today
My.Computer.FileSystem.WriteAllText("D:\Bootdrv\AlohaQS\TMP\FTPBackupDebout.txt", "thisDateFTP Back Up was not Successfully", True) ' Write to the debout the upload failed
Me.Close()
End Try
End Sub
End Class
I have also tried the following.
Try
Dim startPath1 As String = "D:\Bootdrv\AlohaQS\DATA\" ' Setting the DATA Folder For Zipping
Dim startPath2 As String = "D:\Bootdrv\AlohaQS\NEWDATA\" ' Setting the NEWDATA Folder for Zipping
Dim zipPath1 As String = "D:\Bootdrv\AlohaQS\WILL_DATA.zip" ' Nameing the Backup ZIP
Dim zipPath2 As String = "D:\Bootdrv\AlohaQS\WILL_NEWDATA.ZIP" 'Nameing the Back up ZIP
Dim objCurrentDate As Date = DateAdd(-14, , date) As Date
If objCurrentdate = True Then
End If
although I was never able to get that to work as it was always saying it was not declared.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER