0 votes
by (190 points)

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?

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (190 points)
selected by
 
Best answer

No need to answer this, guys, I got the answer now.

I failed to add this line...

client.Seek(0, SeekOrigin.Begin);

This solved the problem.

by (58.9k points)
Thanks for letting us know that you solved the problem in your program and that you are able to upload the files correctly now.
by
Thanks a lot! works for me.
...