1

I want to save my file in disk. I have,

public async Task SaveFileContentsAsync(string filePath, Stream stream)
{
        using (var fileStream = new FileStream(filePath, FileMode.Create))
        {
            await stream.CopyToAsync(fileStream);// await in using is required
        }
}

From my controller I am calling this as,

await _fileService.SaveFileContentsAsync(fullPath, httpPostedFileBase.InputStream)

My file is saving but with 0 KB. What is the issue here?

Imran Qadir Baksh - Baloch
  • 32,612
  • 68
  • 179
  • 322

0 Answers0