Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get extension of file(edit)

i want get extension file of url .

for example get extension http://www.iranfairco.com/download-file/02912bb889cb24. if extension this file is gif.

EDIT:

for example this url "http://www.online-convert.com/result/d8b423c3cbc05000cc52ce7015873e72"

Please help me how can get extension of this url?

like image 890
ashkufaraz Avatar asked Oct 13 '11 10:10

ashkufaraz


1 Answers

Why does Path.GetExtension not work for you?

EDIT
Ah, so your url doesn't specify the extension you are after. That means anything could be behind it.

Just by inspecting the string value of the url, you can't see what will behind it. Your (second) example point (ultimately) to a .gif file, but it could also have been a .jpg, .doc (or even .exe).

You will need to do a webrequest to see what you get back. Usually you could try a HEAD to get just the headers (and inspect the content type), but I don't think that will work here. Try Fiddler to see what you get back, then you can refine your question.

like image 88
Hans Kesting Avatar answered Oct 11 '22 21:10

Hans Kesting