xxxxxxxxxx
String GetBase64FileContent(string fileName, string path)
{
//example of path value, "c:\\temp"
var file = Directory.GetFiles(path, $"{fileName}.*").FirstOrDefault();
if (file != null)
{
Byte[] bytes = File.ReadAllBytes(file);
String base64String = Convert.ToBase64String(bytes);
return base64String;
}
return null;
}
xxxxxxxxxx
byte[] GetFileContentByName(string id)
{
var file = Directory.GetFiles("c:\\temp", $"{id}.*").FirstOrDefault();
if(file != null)
return File.ReadAllBytes(file); return null;
}