C# - Check if a given url is file or directory?
You could use File.Exists(url)
and Directory.Exists(url)
Another approach would be to create an array of extensions then check the result Path.GetExtension(url)
against it.
The following code takes the path, looks at the last substring (after the last /) and checks if there is a '.' in that substring to determine if it is a file or a path. isFile
will be a boolean, true meaning that it is a file.
var isFile = new Uri(url).AbsolutePath.Split('/').Last().Contains('.');