Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 6th, 2008, 1:25 PM   #1
Apophis
Newbie
 
Join Date: Apr 2008
Posts: 16
Rep Power: 0 Apophis is on a distinguished road
Ftp with System.Net.FtpWebRequest

I have the code to upload a file to a ftp sever.
I am just now trying to work out how files that have been uploaded can be deleted and how i can list the uploaded files using the same methods as the upload script (shown below)
Also how to download files would come in handy too.
vb.net Syntax (Toggle Plain Text)
  1. Public Sub UploadFile(ByVal filepath As String, ByVal filename As String)
  2. Dim clsRequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(FtpHost & filename), System.Net.FtpWebRequest)
  3. clsRequest.Credentials = New System.Net.NetworkCredential(FtpUser, FtpPassword)
  4.  
  5. clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
  6.  
  7. Dim bFile() As Byte = System.IO.File.ReadAllBytes(filepath & "\" & filename)
  8.  
  9.  
  10. Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
  11. clsStream.Write(bFile, 0, bFile.Length)
  12. clsStream.Close()
  13. clsStream.Dispose()
  14. End Sub
Apophis is offline   Reply With Quote
Old Jun 7th, 2008, 12:51 AM   #2
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 292
Rep Power: 2 Jabo is on a distinguished road
Re: Ftp with System.Net.FtpWebRequest

I wouldn't expect an answer, seems nobody knows anything about this subject
Previous question unanswered

Either that or nobody wants to answer my posts.

I am currently trying to make a program using ftpwebrequest, and if I can figure it out, I'll let you know.
Jabo is offline   Reply With Quote
Old Jun 7th, 2008, 1:05 AM   #3
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 292
Rep Power: 2 Jabo is on a distinguished road
Re: Ftp with System.Net.FtpWebRequest

This seems to be the meat of the upload and download operations:
MSDN Syntax (Toggle Plain Text)
  1. Specify the FTP command to send to the server by setting the Method property to a value defined in the WebRequestMethods.Ftp structure. To transmit text data, change the UseBinary property from its default value (true) to false. For details and restrictions, see Method.
  2. When using an FtpWebRequest object to upload a file to a server, you must write the file content to the request stream obtained by calling the GetRequestStream method or its asynchronous counterparts, the BeginGetRequestStream and EndGetRequestStream methods. You must write to the stream and close the stream before sending the request.
  3. Requests are sent to the server by calling the GetResponse method or its asynchronous counterparts, the BeginGetResponse and EndGetResponse methods. When the requested operation completes, an FtpWebResponse object is returned. The FtpWebResponse object provides the status of the operation and any data downloaded from the server.
  4. You can set a time-out value for reading or writing to the server by using the ReadWriteTimeout property. If the time-out period is exceeded, the calling method throws a WebException with WebExceptionStatus set to Timeout.
  5. When downloading a file from an FTP server, if the command was successful, the contents of the requested file are available in the response object's stream. You can access this stream by calling the GetResponseStream method. For more information, see FtpWebResponse.
Maybe this will give you your answer.
Jabo is offline   Reply With Quote
Old Jun 7th, 2008, 2:03 AM   #4
Apophis
Newbie
 
Join Date: Apr 2008
Posts: 16
Rep Power: 0 Apophis is on a distinguished road
Re: Ftp with System.Net.FtpWebRequest

This may help- thanks.

If all else fails ill have to use an addin.
Apophis is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DOS FTP help? Jabo Other Programming Languages 3 Sep 7th, 2008 6:44 AM
perl ftp get file once,push x times domquemo Perl 1 Feb 15th, 2008 3:57 PM
FTP Help mattireland HTML / XHTML / CSS 1 Sep 22nd, 2007 9:22 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:46 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC