File tree Expand file tree Collapse file tree
samples/KristofferStrube.Blazor.FileSystemAccess.WasmExample/Pages
src/KristofferStrube.Blazor.FileSystemAccess/Options Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5050 {
5151 handler = await FileSystemAccessService .ShowDirectoryPickerAsync (new DirectoryPickerOptionsStartInFileSystemHandle ()
5252 {
53- Mode = write ? " readwrite " : " read " ,
53+ Mode = write ? FileSystemPermissionMode . ReadWrite : FileSystemPermissionMode . Read ,
5454 });
5555
5656 await LoadItemsAsync ();
7979
8080 if (existing is not null )
8181 {
82- await Js .InvokeVoidAsync (" alert" , " File already exist" );
82+ await Js .InvokeVoidAsync (" alert" , " The file is already exist! " );
8383 return ;
8484 }
8585 }
8686 catch (Exception )
8787 {
8888 // File does not exist
8989 }
90-
90+
9191 var fileHandle = await handler ! .GetFileHandleAsync (FileName , new ()
9292 {
9393 Create = true ,
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ internal override ExpandoObject Serializable()
4444public abstract class BaseDirectoryPickerOptions
4545{
4646 public string ? Id { get ; set ; }
47- public string ? Mode { get ; set ; }
47+ public FileSystemPermissionMode Mode { get ; set ; } = FileSystemPermissionMode . Read ;
4848
4949 internal virtual ExpandoObject Serializable ( )
5050 {
@@ -54,10 +54,12 @@ internal virtual ExpandoObject Serializable()
5454 res . id = Id ;
5555 }
5656
57- if ( Mode != null )
57+ res . mode = Mode switch
5858 {
59- res . mode = Mode ;
60- }
59+ FileSystemPermissionMode . Read => "read" ,
60+ FileSystemPermissionMode . ReadWrite => "readwrite" ,
61+ _ => throw new NotSupportedException ( $ "Unknown Mode value: { Mode } ") ,
62+ } ;
6163
6264 return res ;
6365 }
You can’t perform that action at this time.
0 commit comments