469,608 Members | 2,544 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,608 developers. It's quick & easy.

how to FTP a ZIP file in vb.net to another server

Hi All,
I am facing a problem in Ziping any file and then sending it to another server through FTP.
What I have to actually do is to retrive the property of files of any directory and then find out the last 24 hours modified files. Then copy it into another directory which named as the current system date. Then Zip that folder in which the last 24 hours modified files are present and then FTP to another server.
I have done almost part but unable to rename the folder as current system time and FTP part.
Plz help me regarding this as soon as possible.here is the code what i have written.

Expand|Select|Wrap|Line Numbers
  1. Imports System
  2. Imports System.IO
  3. Imports System.Data
  4. Imports System.IO.Compression
  5. Imports system.IO.Compression.GZipStream
  6.  
  7.  
  8.  
  9.  
  10.  
  11. Public Class MainClass
  12.  
  13.     Shared Sub Main()
  14.  
  15.  
  16.         Dim Now As DateTime = DateTime.Now
  17.         Console.WriteLine("Todays time is" & DateTime.Now.AddDays(0))
  18.         Console.WriteLine("yeasturday  Date is" & DateTime.Now.AddDays(-1))
  19.         Dim myDirectory As DirectoryInfo
  20.         myDirectory = New DirectoryInfo("C:\reg")
  21.         Dim aFile As FileInfo
  22.         For Each aFile In myDirectory.GetFiles
  23.  
  24.             Console.WriteLine("The file named " & aFile.FullName)
  25.             Console.WriteLine("The Creation Time is" & aFile.CreationTime)
  26.             Console.WriteLine("The Last Modified Time is" & aFile.LastAccessTime)
  27.         Next
  28.  
  29.         For Each aFile In myDirectory.GetFiles
  30.  
  31.             If (DateTime.Now.AddDays(-1).ToString <= aFile.LastAccessTime) Then
  32.                 aFile.CopyTo("C:\Arvind" & "\" & aFile.Name)
  33.                 Console.WriteLine(aFile.FullName & " File has been last modified in the past 24 hours at" & aFile.LastAccessTime)
  34.                                 System.IO.Directory.Move("C:\Arvind", "Current System time")
  35.  
  36.                             Console.WriteLine("Files has been renamed")
  37.             End If
  38.              Dim s As ICSharpCode.SharpZipLib.Zip.ZipOutputStream = New ICSharpCode.SharpZipLib.Zip.ZipOutputStream(System.IO.File.Create("C:\testfile2.zip"))
  39.               s.SetLevel(9) ' 0-9, 9 being the highest level of compression
  40.               Dim buffer() As Byte
  41.              ReDim buffer(4096)
  42.              Dim filenames As String() = Directory.GetFiles("C:\DataTime.now")
  43.              Dim f As String
  44.              For Each f In filenames
  45.             Dim entry As ICSharpCode.SharpZipLib.Zip.ZipEntry = New ICSharpCode.SharpZipLib.Zip.ZipEntry(Path.GetFileName(f))
  46.              entry.DateTime = DateTime.Now
  47.              s.PutNextEntry(entry)
  48.               Dim fs As FileStream = System.IO.File.OpenRead(f)
  49.              Dim sourceBytes As Integer = 1
  50.               Do Until (sourceBytes <= 0)
  51.             sourceBytes = fs.Read(Buffer, 0, Buffer.Length)
  52.               s.Write(Buffer, 0, sourceBytes)
  53.               Loop
  54.             fs.Close()
  55.              Next
  56.              clean up
  57.             s.Finish()
  58.             s.Close()
  59.         Next
  60.  
  61.     End Sub
  62. End Class
Aug 5 '08 #1
3 2061
Hi All,
Plz help me regarding how to FTP a ZIP file in vb.net to another server
Aug 6 '08 #2
Curtis Rutland
3,256 Expert 2GB
"Plz" help yourself to a tutorial. I'm sure that google has plenty.
Aug 6 '08 #3
Plater
7,872 Expert 4TB
Threads Merged.
Please do not double post your questions, it is against the posting guidelines.
MODERATOR
Aug 6 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by hntgzr | last post: by
6 posts views Thread by =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.