I have to use File.WriteAllBytes() to store the file contents.
If file.Filename
is a string without spaces it works fine (like "abc","sample"). But if file.FileName
comes with values like "power bi report", "March report" ,throws error.
File.WriteAllBytes($"D:\\PowerBi Console\\PowerBiConsole\\{file.FileName}.pdf",file.FileContents);
file
is a FileModel
instance and
public class FileModel
{
public byte[] FileContents { get; set; }
public string ContentType { get; set; }
public string FileName { get; set; }
}