473,785 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

10 New Member
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 2274
coolestavi007
10 New Member
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 Recognized Expert Specialist
"Plz" help yourself to a tutorial. I'm sure that google has plenty.
Aug 6 '08 #3
Plater
7,872 Recognized Expert Expert
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
2758
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 program form vbnet.mvps.org but it doesn't work?? Greets John
7
2690
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 updated every hour or so. How can I do this easily? I would like to use secure communication even encryption if possible. I would query and insert locally only the newest records found in that XML file to an xml or MS access db.
14
3560
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 line but not from a browser. The page does not throw an error but the oShell.Run... portion of the script doesn't run. Any help would be appreciated. Thanks.
5
2299
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; include(http://www.anotherserver.com/foldername/phpfiletocall.inc); The .inc file is php formatted. Variables are passed to it (not via GET or POST though) and returned using return(variablenames, etc);
6
4017
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 through our firewall. We have another server (Server1) within the SBS domain that is exposed through port 80 of the firewall on which we host some web services and images. What is the best architecture for getting the file from the remotely...
8
9764
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 problem: my vb.net program has problems with UNC. If the UNC server is restarted or goes off-line, my VB.net program crashes. The code for UNC access to the file is included below and is put in the tick event of a form timer control running every...
0
2962
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 resuming for the file uploading if the client connection or server connection is down. E.g: Sunset.jpg (500KB) when i upload until half of it, (332KB in the server) and unplug my connection, it will looping and try to connect to the server, after...
6
4929
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 and the file is copied from the server to the server, rather than from the web client to the server. Please help!!!
7
7158
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 Silverlight 2.0. To get these tools please visit this page Get Started : The Official Microsoft Silverlight Site and follow Step 1. Occasionally you find the need to have users upload multiple files at once. You could use multiple FileUpload...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.