Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I wanted to get File type (File Extension) from Base64String in ASP.NET

I have web method in which I have passed 1) Base64 string and 2) File Name with File Extension
but now I wanted to Pass 1) Base64 String and 2) Only File Name (Without Extension)

So Can I get that Extension from that Base64 String / how can i get that base64 Encoded File's Extension.

Thanks.
Posted

1 solution

Unless the extension is contained within the data converted to base64, then no, you probably can't.
It may be possible to look at the data and decide if it is one of a small range of types, but that will depend on the types that you are checking for, and their individual data formats.

There is no generic data section which says "this binary data is xxx type" (that is what the file extension is there for)
 
Share this answer
 
Comments
GauravThorat 17-Jul-13 3:19am    
I have Converted that data from .NET

I am using below line for covering file to base64,
can i get file extension using this code:

string base64str = System.Convert.ToBase64String(ArrFile,0,ArrFile.Length)


Thanks
OriginalGriff 17-Jul-13 3:56am    
No.
Unless you have added the info to your data in the ArrFile array, then you do not convert it to base64, so you cannot recover it.
GauravThorat 17-Jul-13 4:29am    
Actually I am getting the Base64 string from iPhone and after processing the videos and images are working but only my question is how can i get the file extension from base64 string.
OriginalGriff 17-Jul-13 4:42am    
You can't.

Unless the info is in the string (and your code shows no sign of that) then you have discarded the info and cannot get it back.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900