.Net Framework 2.0 came with many new features which helps the developers in solving daily routines problems/quires while developing an application either windows or desktop. Today as we have seen Web Application became the part of our life. When we are facing any difficulty regarding development we took help from web application, similarly, when we want to purchase any thing we look for e-commerce websites.
Since we are a part of 21st century and in this century we have seen many developments in technology. Technology facilitates users in many ways for example, remote universities. Student sitting on one end and university on the other, to transfer course content, lectures etc. usually FTP (File Transfer Protocol) is used. When we talk about .Net Framework 1.0 we didn’t see any facility in using FT Protocol. .Net Framework 2.0 provides us FTPWebRequest and FTPWebResponse classes. These two classes provide complete ease to developers to implement an entire FTP client right from their web application. To get more understanding about these classes consider an example that upload file from local system to ftp://localhost/. You can also transfer file to live servers by providing network credentials (UserID, PWD).
To begin with this application create new website in VS2005. Add two controls one is label control and other is button control. Your .aspx source view page looks like this:
<asp:Label ID="lblMsg" runat="server" /><br /><br />
<asp:Button ID="cmdUpload" Text="Upload" runat="server" />
Public Sub uploadFileUsingFTP(ByVal CompleteFTPPath As String, ByVal CompleteLocalPath As String, Optional ByVal UName As String = "", Optional ByVal PWD As String = "")
'Create a FTP Request Object and Specfiy a Complete Path
Dim reqObj As FtpWebRequest = WebRequest.Create(CompleteFTPPath)
'Call A FileUpload Method of FTP Request Object
reqObj.Method = WebRequestMethods.Ftp.UploadFile
'If you want to access Resourse Protected You need to give User Name and PWD
reqObj.Credentials = New NetworkCredential(UName, PWD)
'FileStream object read file from Local Drive
Dim streamObj As FileStream = File.OpenRead(CompleteLocalPath)
'Store File in Buffer
Dim buffer(streamObj.Length) As Byte
'Read File from Buffer
streamObj.Read(buffer, 0, buffer.Length)
'Close FileStream Object Set its Value to nothing
streamObj.Close()
streamObj = Nothing
'Upload File to ftp://localHost/ set its object to nothing
reqObj.GetRequestStream().Write(buffer, 0, buffer.Length)
reqObj = Nothing
End Sub
Protected Sub cmdUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdUpload.Click
'On button Click call the function
'and Pass Parameter Values
'Display Message on Success
uploadFileUsingFTP("ftp://localhost/ftp1.txt", "C:\Documents and Settings\Administrator\Desktop\ftp.txt")
lblMsg.Text = "File Uploaded Successfully :)"
Posted on 5/26/2006 12:20:01 AM by NAUMAN
Posted on 6/1/2006 6:59:47 AM by vikas
Posted on 6/2/2006 6:02:50 AM by DevASP
Posted on 6/6/2006 12:12:27 PM by Peter
Posted on 8/15/2006 8:46:20 AM by Daniel
Posted on 8/16/2006 2:34:42 PM by jack
Posted on 9/5/2006 5:18:36 AM by seshu
Posted on 9/25/2006 5:17:48 PM by Vincent
Posted on 10/15/2006 12:53:53 PM by ashish
Posted on 10/16/2006 1:36:55 PM by Anoop Gupta
Posted on 12/5/2006 8:52:32 PM by Khanh ly
Posted on 1/11/2007 5:11:45 PM by paul noeldner
Posted on 1/19/2007 1:28:06 AM by Jagannath Sahoo
Posted on 5/3/2007 4:27:57 AM by J Widberg
Posted on 5/3/2007 8:08:43 AM by Michael O'Donnell
Posted on 5/10/2007 1:18:22 AM by prabhakar
Posted on 5/10/2007 9:04:23 AM by choudhry
Posted on 5/12/2007 2:01:14 AM by Ajith Alex M
Posted on 6/22/2007 1:16:05 AM by Murali
Posted on 6/26/2007 4:01:36 AM by manish jain
Posted on 7/19/2007 3:08:00 AM by Kien
Posted on 8/7/2007 1:08:01 AM by Hetal Patel
Posted on 8/7/2007 3:10:41 AM by Ishfaq
Posted on 8/8/2007 4:51:43 PM by Rachea
Posted on 8/16/2007 2:24:31 AM by RajyaLakshmi.M
Posted on 8/16/2007 2:55:41 AM by harshitha
Posted on 8/16/2007 3:06:41 AM by Harshitha
Posted on 8/24/2007 7:06:31 AM by Amit
Posted on 10/9/2007 12:48:11 PM by rprinfo
Posted on 10/23/2007 2:25:09 PM by Robert S. Robbins
Posted on 11/2/2007 8:00:03 AM by satish
Posted on 11/4/2007 4:47:45 PM by deostroll
Posted on 11/10/2007 1:22:24 AM by Gilbert Figueroa
Posted on 11/17/2007 5:24:32 AM by pradeep
Posted on 11/17/2007 5:29:03 AM by pradeep
Posted on 11/28/2007 11:03:10 PM by pravin
Posted on 11/28/2007 11:03:49 PM by pravin parmar
Posted on 12/4/2007 3:23:53 AM by check
Posted on 12/6/2007 2:07:45 AM by Gagan
Posted on 12/18/2007 5:07:47 PM by thoughtcriminal
Posted on 12/18/2007 5:08:18 PM by thoughtcriminal
Posted on 12/21/2007 4:04:40 AM by Parag
Posted on 12/28/2007 2:20:06 AM by Francis
Posted on 1/18/2008 6:58:41 AM by Leen
Posted on 1/28/2008 6:16:14 PM by Zach
Posted on 2/1/2008 6:46:14 AM by girish
Posted on 3/12/2008 6:58:07 AM by Micha Brans
Posted on 4/8/2008 8:40:50 PM by CMC
Posted on 4/9/2008 5:38:06 AM by terence
Posted on 4/16/2008 4:13:42 AM by Alon Chalmers
Posted on 5/2/2008 3:02:04 AM by Sejal
Posted on 5/22/2008 8:50:25 AM by Jawad Naeem
Posted on 5/25/2008 4:38:56 AM by Hamid
Posted on 9/18/2008 5:42:49 AM by arun
Posted on 10/28/2008 3:21:21 AM by chaitanya
Posted on 12/4/2008 8:09:42 AM by Senguttuvan G
Posted on 11/21/2009 7:41:12 AM by Murali
Posted on 12/4/2009 11:14:27 AM by nazo tajrian
Posted on 12/29/2009 2:12:05 AM by chekuri.ravikumar
Posted on 1/25/2010 2:24:05 AM by satya
Posted on 1/29/2010 6:01:12 AM by pradeep kumar
Posted on 2/9/2010 2:37:27 AM by Ashutosh
Posted on 3/3/2010 4:43:13 AM by Paul