Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to get file type from base64 in c#

/// <summary>
/// To demonstrate extraction of file extension from base64 string.
/// </summary>
/// <param name="base64String">base64 string.</param>
/// <returns>Henceforth file extension from string.</returns>
public static string GetFileExtension(string base64String)
{
var data = base64String.Substring(0, 5);

switch (data.ToUpper())
 {
     case "IVBOR":
        return "png";
     case "/9J/4":
         return "jpg";
     case "AAAAF":
         return "mp4";
     case "JVBER":
         return "pdf";
     case "AAABA":
         return "ico";
     case "UMFYI":
         return "rar";
     case "E1XYD":
         return "rtf";
     case "U1PKC":
        return "txt";
     case "MQOWM":
     case "77U/M":
        return "srt";
     default:
        return string.Empty;
 }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: static c# 
Csharp :: c# operator overloading 
Csharp :: windows forms get all images from resources 
Csharp :: how to add a force to an object unity 
Csharp :: c# allowedusernamecharacters 
Csharp :: c# convert to nullable datetime 
Csharp :: Kill System Process in C# 
Csharp :: string tochararray c# 
Csharp :: c# add 2 arrays 
Csharp :: c# max two values 
Csharp :: c# funtion 
Csharp :: interpolate rotation unity3d 
Csharp :: datatable iqueryable c# linq 
Csharp :: unity reset random seed 
Csharp :: print a file from C# 
Csharp :: c# convert datetime to year & month 
Csharp :: on collision unity 
Csharp :: c# listview add item 
Csharp :: linq datatable 
Csharp :: c# remove time in datetime 
Csharp :: C# int array initial values 
Csharp :: delay activity in uipath 
Csharp :: serilog .net 6 
Csharp :: euler to quaternion 
Csharp :: c# get last array element 
Csharp :: c# get smallest of 3 numbers 
Csharp :: get index brushes properties c# 
Csharp :: C# Blocks with statements 
Csharp :: c# chance of 
Csharp :: conncet oracle database in c# visual studio 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =