Blazor.FileSystemAccess icon indicating copy to clipboard operation
Blazor.FileSystemAccess copied to clipboard

How to check if a file exists

Open alecava58 opened this issue 2 years ago • 5 comments

Hi,

I looked at the source code but I didn't find how to check if a file exists before reading.

Thanks

alecava58 avatar Nov 08 '23 13:11 alecava58

Hey @alecava58, the user can only select files that are present. You can indeed have a file handle for a file longer than the actual file lives. I will explore the exact behavior for this and ensure there is a way to discover if the file no longer exists.

KristofferStrube avatar Nov 08 '23 20:11 KristofferStrube

Hi Kristoffer, thanks for quick reply.

What I'm looking for is a function like System.IO.File.Exists(filename) and if the function returns true upload the file in client memory.

alecava58 avatar Nov 09 '23 08:11 alecava58

You can't open arbitrary files. Only files that the user has directly opened or files present in directories that the user has chosen directly. In the directory case, you can very easily get a list of all files and folders in it and continue from there.

KristofferStrube avatar Nov 09 '23 08:11 KristofferStrube

Ok. I understand.

Thanks for sharing your useful library.

alecava58 avatar Nov 09 '23 09:11 alecava58

I'm keeping this issue open to explore what exceptions we should get when trying to read a file that has been moved.

KristofferStrube avatar Nov 09 '23 09:11 KristofferStrube