I am building an excel file and saving it to a MemoryStream with ClosedXML.
From the MemoryStream, the file is either sent as an attachment through email or uploaded to the server using Rebex PutFile.
I am not using Rebex for the email and there's no problem with it. The file is sent well. The problem lies with the file saved in the server. Yes, it is being uploaded but once I try to open it, there is the error... "…file format or extension not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
I tried uploading an excel file that is saved from my local PC. There's no problem with it after FTP. Only those excel files from MemoryStream have this problem. When I tried using the same code to FTP a CSV file from MemoryStream, the file works well.
I only have this problem with Excel files from MemoryStream.
What can I do to prevent the file from being corrupted?