Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

FileStream.CopyToAsync copies the file empty with size of 0

$
0
0

Hi

I'm trying to upload files to some destination folder in wwwroot source folder.

Now when I browse some file and save a new record in the view, the file is copied but empty with 0 size!

I've tried to put these bold in the method:

                using (var fileStream = new FileStream(newfilepath, FileMode.Create))
{
fileStream.Position = 0;
fileStream.Flush();
await fileStream.CopyToAsync(fileStream);
}

but this doesn't solve the problem. How to solve please?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>