List web file folder

Asked

Viewed 427 times

1

I’m trying to list a folder of files, I’m not getting,

the error says that the directoryinfo does not support URL.

DirectoryInfo directoryinfo = new DirectoryInfo("http://127.0.0.1");
IEnumerable<FileInfo> fileList = directoryinfo.GetFiles();
  • And what more than already informed you want to know?

  • @mustache was just that.

1 answer

1


For HTTP there is no way to do it this way. Actually there will have to be API and remote access that allows you to do by HTTP.

If you just want to take the data on the network and can be by any protocol there you can do direct access, as you would on Windows, so:

var fileList = Directory.EnumerateFiles(@"\\127.0.0.1");

I put in the Github for future reference.

Of course you also need to have permission to access the machine, which is right on localhost and probably need to specify the directory to work.

I used the EnumerateFiles() because it performs better.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.