C # .NET Deleted File List Contents

Is it possible in .NET to list files in a remote location as a URL? Similarly, the System.IO classes work. All I need is the URLs of the images that are on the remote server.

+4
source share
2 answers

Short answer: No, unless you have more control over this web server.

Long answer: Here are the possible solutions ...

  • You will need a server-side script that does this locally and displays this list in the preferred format.

  • Most web servers implement default file browsing pages, so you can theoretically parse them, but this solution will be very fragile and not very portable even between different versions of the same web server.

  • If you have FTP access ...

+4
source

Is it possible in .NET to list files in a remote location, such as a URL?

You must indicate which protocol we are talking about.

For HTTP, lubos hasko provided the answer: no. HTTP has no concept of files; only resources. If you have control over the web server, you can ask it to provide a list of directories, or, even better, you can write the code that the server server displays for you. Without such control, you need to rely on the server to provide a listing that 1) can be disabled for security reasons, 2) not standardized in its format, 3), like lubos, will be fragile for analysis ( "scrape" ).

If you mean / if the server provides a protocol designed to transfer files such as FTP, SMB / CIFS, etc., it will be much easier. For example, for FTP, you want to see WebRequestMethods.Ftp.ListDirectoryDetails .

+2
source

Source: https://habr.com/ru/post/1276351/


All Articles