473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 2240
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

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

Similar topics

3
by: John | last post by:
Hello, I need to know which programs are opn on another machine in my network, these programs are opened from a shared drive on the server. How can I do this ? I've already dowloaded a sample...
7
by: Dan V. | last post by:
Situation: I have to connect with my Windows 2000 server using VS.NET 2003 and C# and connect to a remote Linux server at another company's office and query their XML file. Their file may be...
14
by: Mark C. | last post by:
I'm trying to call a batch file that I've built using the FileSystemObject and CreateObject("Wscript.Shell"), oShell.Run... in an asp script. Naturally, I can get the script to work from a command...
5
by: hntgzr | last post by:
I am trying to include a function in a .php file on a different server from the main .php files. I am using: include_path=http://www.anotherserver.com/foldername;...
6
by: Pat Carden | last post by:
Hi, We need to allow webusers to upload a file on our website (on Server3, all servers run Server 2003, remotely hosted) and eventually save it on our SBS Server (Server2) which is not exposed...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
0
nightangel
by: nightangel | last post by:
Hi dude,what i was done in my application is uploading a image file to my server using FTP, it work great when pushing a file into the server path using FTP. The problem i met now is i need to do a...
6
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an error: Could not find file 'C:\testfile.xls'. If I add the file (c:\testfile.xls) to the server I do not get the error...
7
Curtis Rutland
by: Curtis Rutland | last post by:
Building A Silverlight (2.0) Multi-File Uploader All source code is C#. VB.NET source is coming soon. Note: This project requires Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1 and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.