Exception when trying to save file stream in local directory.

Dani_S 2,746 Reputation points
2023-05-28T12:40:18.6266667+00:00

Hi,

I got this exception when trying to download file and keep it in my local folder.

The input is stream and the expected output:

is file.

Access to the path 'D:\Push1' is denied.

   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
   at System.IO.File.Create(String path)
   at GssdDesktopClient.Maui.ViewModels.DownloadViewModel.<<InitCommands>b__149_4>d.MoveNext() in D:\Applications\GssdDesktopClient\GssdDesktopClient.Maui\ViewModels\DownloadViewModel.cs:line 786

Environment Information: Net 6 using MAUI, Windows platform

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,926 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Dani_S 2,746 Reputation points
    2023-05-28T14:07:53.24+00:00

    It solved, there was problem with file path.