-3

It should be well known that a internet URL can point to either a folder or a file.
A folder usually responds with a default page -- e.g. index.html. A file responds with itself.

In either case, you don't know which one you are getting. Imagine for instance ("http://www.example.com/fileorfolder.html"). Is it an oddly named folder that is returning a default file or is it a file?

How do I tell?

Keeper
  • 31
  • 8
  • maybe this would help? http://stackoverflow.com/questions/1395205/better-way-to-check-if-path-is-a-file-or-a-directory-c-net – proggrock Nov 28 '12 at 01:35
  • 1
    the web doesn't have folders, just urls that point to resources. – spender Nov 28 '12 at 01:35
  • Ok... but because I need to build a localized simulation of any given website, I need to determine ("address bar speaking") the "map" of it, regardless of what one calls the areas of a site. – Keeper Nov 28 '12 at 01:57
  • So what you're really asking isn't how to determine if something is a "folder" or a "file," but rather how to determine the hierarchical structure of some Web site. I know of no other way than to crawl the site and keep track of the URLs, then parse the segments. – Jim Mischel Nov 28 '12 at 02:37

2 Answers2

3

Your assumption is wrong - (outside of WebDAV) there are no "folders" or "files" on the web, only arbitrary resources.

If a web server is configured to map a resource path to a filesystem (as most, but not all, are by default) then accessing a "folder" still returns a HTML document, only the document contains a listing of files - but the format of this document varies depending on the software used.

Why are you wanting to know anyway?

Dai
  • 141,631
  • 28
  • 261
  • 374
0

It may be best to check if you are redirected from the requested URL to a different URL.

Check out this link.

C# detect page redirect

Community
  • 1
  • 1
taylorjonl
  • 869
  • 9
  • 15