C# : FTP How to identify 550 ftp error ,the Directory already exists or Directory not found

StackOverflow https://stackoverflow.com/questions/4841678

  •  27-10-2019
  •  | 
  •  

Question

C# : FTP How to identify 550 ftp error ,the Directory already exists or Directory not found. Because 550 is can be both of them.

Was it helpful?

Solution

Directory already exists can only happen when you're trying to create a directory. So if you're creating a directory and you get a 550, then that's the one.

Directory not found can only happen while browsing to a directory. So again this is easily identifiable given what action you where doing.

OTHER TIPS

Simple answer is: you can't. Even if "directory already exists" can only happen when you are trying to create a directory, it may still return 550 for other reasons such as a missing or otherwise unaccessible parent directory.

The best you can do is to check for a return code of 550, and then check if the directory made it there by requesting its file listing. If it already exists, you'll get a listing, if not, you'll get an error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top