public string ContructOrganizationNameLogo(HttpPostedFileBase upload, string OrganizationName, int OrganizationID,string LangName) { var UploadedfileName = Path.GetFileName(upload.FileName); string type = upload.ContentType; }
I want to get the extension of the file to dynamically generate the name of the file.One way i will use to split the type. but can i use HttpPostedFileBase object to get the extension in the clean way?
string extension = Path. GetExtension(upload. FileName);
ASP.NET pages have the extension . aspx, and are normally written in VB (Visual Basic) or C# (C sharp). User controls in ASP.NET can be written in different languages, including C++ and Java.
The Razor syntax consists of Razor markup, C#, and HTML. Files containing Razor generally have a . cshtml file extension.
bool CheckFileType(string fileName) { string ext = Path. GetExtension(fileName); switch (ext. ToLower()) { case ". gif": return true; case ".
Like this:
string extension = Path.GetExtension(upload.FileName);
This will include a leading .
.
Note that the you should not assume that the extension is correct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With