FTP usage

Hi.
Using .NET 2.0 and its the first time im using the FTP protocol in development.

I am trying to issue a few commands, firstly it works fine such as listing a directory however if i wish to disconnect from the server using, lets say "QUIT" or perhaps I wish to upload /download a file, I get an error saying:

"This operation cannot be performed after the request has been submitted."


Am I doing something wrong or must I create another FtpWebRequest object per command

Other thing is, if i explicitly specify a method with a NEW FtpWebRequest, a command to "QUIT" or even "CD dir" it gives me an exception that the method is not supported or rather the parameter is not supported.

What about checking to see if a specified path is a file or a directory The IsFile property does not seem to work as it always returns false when you create a new FtpWebRequest and give it the entire path to the directory OR file.

Am I doing something wrong




Answer this question

FTP usage

  • Solvej Smith

    For the IsFile Property:
    WebRequest.RequestUri.IsFile should not be used to check for an ftp file or directory.
    The ftp LIST method should be used (not NLST) and then the response parsed

    Mariya 

  • Shri73463

    The FTPWebRequest we have today is based on the WebRequest/Response semantics so it has some interesting consequenses.

    1) You don't need to send QUIT command. It is automatically done that for you
    when you close the response
    2) You need to create a new FTP request after each major operation

  • Kris Ganjam

    Following blog posting may also be interesting for you
    http://blogs.msdn.com/adarshk/archive/2004/09/13/229069.aspx

  • NavneetSharma

    The delete problem does not reproduce on our servers.
    To be able to test it on your machine I'll need to connect to it. Can you add a user testftp and e-mail me the credentials for it at mariya@microsoft.com.donotspam

    For the IsFile property I didn't quite understand what you meant. FtpWebRequest doesn't currently have IsFile property. You can use the LIST method instead of NLST and it will show you which is a file and which is a directory

    Let me know if this helped
    Mariya

  • sachleen

    We will try to look at this today.
    Is your FTP server reacheable over the Internet

  • Verrkomies

    Hi there.

    Yes it is reachable however I would require to email you the username/password access.

  • CamonZ

    When you are using IE, it sometimes uses HTTP tunneling when going through proxy. if you are going through a proxy then this could be the case. If you capture a netmon trace, then you can confirm this.
    The user that is accessing the files could be
    IUSR_DGORTITBL. This user needs to have permissions on the directory.

    Could you please turn on the security audit on the computer We can then clearly see who is accessing and who is denied.  To turn on securutiy auditing use Local Security policy of the secpol.msc.

  • JaseT

    Thanks to these wonderful people, I have resolved the issue and it was a silly mistake from my end! typical me! I apologise.

    I was using "RemoveFile" instead of "RemoveDirectory" which was causing the "access denied" error message.

    This is what to check for if you have this problem! :)

  • Radu C-tin

    Hi there.

    Yes, I did try this but there were no audits being logged as failed. IE is not using a proxy server, there are no proxy connections configured.

    However I do not understand why a 3rd party ftp client program does it fine, it can delete files. Not only this, IE deletes it fine too but its just only the C# application that seems to be getting access denied as well as the command prompt FTP application built into Windows.

  • Devteam

    Hi there. Thanks for this!

    I have just emailed you the access details.

    as for the IsFile property, this is in the WebRequestObject.RequestUri property.

    However for now, let us stick to the main issue of the folder/file not being able to delete even though appropriate credentials/access has been given as well as the fact that it deletes it from IE or a 3rd party FTP program :-)



  • JIM WALL

    Thanks for that! Cool, so I was on the right lines.

    A couple more questions if you dont mind...

    I cannot seem to Delete a file/folder. I get access denied. The wierd thing is that if i use IE to FTP into the same site or even a 3rd party client, it works fine! I can delete

    If I use this C# app or even the command prompt FTP, I get access denied to delete a folder the user has created using that account. Full permissions have been given to the directory the user is accessing and IIS has been told to grant Write Permission and Read for that Virtual Directory.

    lastly, hopefully, how do I detect the file type of a selected file how can I found out that if I give a full path, if it is a file or not is it possible

  • FTP usage