I know the file's name, that is saved on server, I want to get the contentType of that file that is saved on server, what I want is something like this:
string loc = Server.MapPath("~/Content/Images/document.*");
But the above code is not working and the error says :
Illegal character is specified i.e.(*)
My question is, how to get the extension and the content type of the file name that I know and is saved on server?
ContentType. So basically you could associate this information with the file by the time it gets uploaded and persist it in your datastore. Then just look at the datastore the corresponding ContentType given a filename. On the other hand if all you need is the file extension, then this is quite easy using the Path.GetExtension method.