Save Files With Just 1 Line of Code with .NET MAUI FileSaver!

  Рет қаралды 14,464

Gerald Versluis

Gerald Versluis

Күн бұрын

Пікірлер: 93
@jfversluis
@jfversluis Жыл бұрын
Saving files goes perfectly with picking a folder, don't you think? Good thing I have a video on FolderPicker as well 📂 kzbin.info/www/bejne/ooDdcop9qLx-nJY Or you just enjoy watching my videos? Then I have a playlist about .NET MAUI in general for you, right here 👉 kzbin.info/www/bejne/ooDdcop9qLx-nJY
@acodersjourney
@acodersjourney 10 ай бұрын
A big shoutout for the incredible work you do in simplifying coding challenges. Your videos have been a lifesaver!
@jfversluis
@jfversluis 10 ай бұрын
Appreciate that 🥰 thank you!
@marshalstewart7776
@marshalstewart7776 Жыл бұрын
Literally was googling docs on how to use feature in the community toolkit today and saw the video posted later. Great stuff appreciate the great videos!
@jfversluis
@jfversluis Жыл бұрын
Haha that is great! Hope this was helpful then!
@sandeepsirohi8434
@sandeepsirohi8434 Ай бұрын
Hi Gerald, Thanks for a nice video as usual. One question though, Is it possible to store files/data in a folder on root/internal memory(API 34)?
@ademineshat
@ademineshat Жыл бұрын
Thanks for sharing. You asked for opinions ☺️ I would say short and simple: "little things or details make the difference" 👍 I see in every video you go very quick and skip the details. I would be nice to have complete tutorials, which will look nice and also fully functional. This was my opinion! Thank you
@jfversluis
@jfversluis Жыл бұрын
Thanks! To be honest there aren’t much more details to this 🤷‍♂️ also each app will be different. One person will want to see all the details that fits in their app wile someone else might be interested in another thing. It will be impossible to make the perfect video for everyone. That’s why I try to show you the basics and how to get started so you can take it from there and make it fit in your own situation. Thank you, appreciate it!
@berniemueller2827
@berniemueller2827 Жыл бұрын
Could you also do a video on saving a file to External Storage, so that the user of the device could access the file outside of the app?
@josedonizeteoliveirajunior1744
@josedonizeteoliveirajunior1744 Жыл бұрын
It really got easier! thank you amazing channel
@jfversluis
@jfversluis Жыл бұрын
Thank you! I would maybe like to see also an option where you can save a file without showing a dialog first. Would that be helpful?
@josedonizeteoliveirajunior1744
@josedonizeteoliveirajunior1744 Жыл бұрын
@@jfversluis Certainly
@ebrahimmehri
@ebrahimmehri 9 ай бұрын
Excellent! Thank you.
@jewersp
@jewersp Жыл бұрын
This is awesome, Gerald. It would be great to see how this works on the other platforms.
@jfversluis
@jfversluis Жыл бұрын
It should be more or less the same, go try it out ;)
@GianfrancoTronu
@GianfrancoTronu Жыл бұрын
Thank You very much indeed for this video !
@jfversluis
@jfversluis Жыл бұрын
You’re very welcome!
@MatiHalek
@MatiHalek 10 ай бұрын
Hello, thank you (from Poland) for all these videos! They help me because I'm struggling with MAUI, especially with random exceptions without description. Also, I have a question because I'm doing a school project with MAUI (advertising system): I would like to know if it is possible to save an image downloaded from FilePicker (my last line: var stream = await result.OpenReadAsync();) to the project directory (e.g. Images, instead of showing dialog) and how to then specify the target path in code?
@navarone77
@navarone77 10 ай бұрын
Hey there, I was also having troubles turns out for me the FilePicker and a few others have changed, you no longer need to dependency inject it and you can use the static class directly. Remove IFilePicker from AddSingleton, remove it from Constructor on MainPage and just change the line to be: await FileSaver.Default.SaveAsync(etc...) Hope it helps
@x12624
@x12624 Жыл бұрын
Hi Gerald, This is cool. I am guessing this can only be used on the client side, but not server side. For example, can I use this in a class library that's running on a server?
@jfversluis
@jfversluis Жыл бұрын
.NET MAUI is client-side so yes, this only works on the client
@flrcml69
@flrcml69 4 ай бұрын
Hi @Gerald Versluis How to save a file .db with FileSaver in a chois folder with FolderPicker?
@tahirkhan466
@tahirkhan466 Жыл бұрын
Thanks for the hard work, please make a tutorial on how to see an image from a list of images in full screen and then we will have options to delete or save that image in the device gallery using .net MAUI
@Neha-lh6ok
@Neha-lh6ok Жыл бұрын
Thanks for sharing ! i was able to save the file but unable to open the attachment in its downloaded format example if i am downloading the png or jpg file the file format is being corrupted or is not in supported format same goes with txt or pdf files can you please suggest something to resolve this
@anandshindey
@anandshindey Жыл бұрын
very nice, just what I needed. Thanks.
@jfversluis
@jfversluis Жыл бұрын
Thanks great, good luck!
@abelanil
@abelanil Жыл бұрын
As you say, is amazing. Thanks
@jfversluis
@jfversluis Жыл бұрын
You’re welcome!
@AthiraRNAIR-gr7gc
@AthiraRNAIR-gr7gc 9 ай бұрын
Hello. I was going through an option to download a large file in Maui. One time it's working with file Saver communitkit. For large files our api pull it as chunks. So need to merge and create the actual file. Can you help me if you have any idea on if this supports that . Also a progress bar , as it's big and user needs to know how long to wait ofcourse. 😊 It ll be very helpful if you can give some pointers. From India 😊
@TechnoNewsUpdates
@TechnoNewsUpdates 7 ай бұрын
How to update the content of zip folder as i use filesaver to save the file but i don't have idea to update the file as i tried to get the modifiedstream and have an idea to just place that stream inside new zip file and delete that existing one but can we get the real path of that file so i can save over there.
@earthlingthings
@earthlingthings 4 ай бұрын
So, what if I wanted to do this dialogue from a viewmodel class or any other sub class not on the xaml.cs page?
@jfversluis
@jfversluis 4 ай бұрын
Wrap it in some kind of service class and maybe use dependency injection
@earthlingthings
@earthlingthings 24 күн бұрын
There is an issue when user omits the file extension. Eg .txt the file gets saved without an extension. Can we not have a passed in file type which forces an extension??
@jfversluis
@jfversluis 22 күн бұрын
Make sure to report it to the repo!
@chezchezchezchez
@chezchezchezchez Жыл бұрын
I saw you traversed the file system and opened the newly created file. Perfect. How do you do that on the android emulator ? Thank you very much.
@chezchezchezchez
@chezchezchezchez Жыл бұрын
Anyone?
@jfversluis
@jfversluis Жыл бұрын
Not sure what you mean :)
@chezchezchezchez
@chezchezchezchez Жыл бұрын
@@jfversluis I think I figured it out but what I meant was …. You had windows “pop up” a file dialog box where you could select a file. I wanted to see that on Android! I ran it at home and it seems to work. (Shows android file picker thing) Why doesn’t “file filter” (show images or audio files only) have one for .txt or text files? Also what’s the best way to have a user save/import text files? I want them to backup/restore the SQLite db. Thanks!!
@davidsutton6863
@davidsutton6863 Жыл бұрын
Can you show us how to store a file without the user dialog please Gerald?
@jfversluis
@jfversluis Жыл бұрын
Sure! What's not clear? It should not be different than regular .NET: File.SaveAllText("file.txt", myLinesCollection);
@davidsutton6863
@davidsutton6863 Жыл бұрын
@@jfversluis Thanks Gerald, that did the trick.
@DanielAncines
@DanielAncines Жыл бұрын
Hey Gerald, how are you doing? Did you notice if you click Cancel on the Dialog Window, the program crashes? I've been getting CommunityToolkit.Maui.Storage.FileSaveException: 'Path doesn't exist.'. See yaa! Update: forget, I saw on your repo that you put a try there, is this an expected behavior or an issue?
@jfversluis
@jfversluis Жыл бұрын
It's demo code... ;) Yeah that is why I mention that you need to do a try/catch around it. It throws an exception when you cancel. Personally I thought this was very weird so provided that feedback and I think PRs are being merged right now to change that behavior. Thanks!
@DanielAncines
@DanielAncines Жыл бұрын
@@jfversluis yeah, I think the same, thank you!
@surdz
@surdz Жыл бұрын
can i implement this in maui blazor?
@jfversluis
@jfversluis Жыл бұрын
Yep!
@markusf.meisinger5832
@markusf.meisinger5832 Жыл бұрын
Hi Gerald, always appreciate your videos a lot! Can you show this how it is done on .NET 7 Android 13 API 33? Thanks! It works like a charme on Android less then API 33
@markusf.meisinger5832
@markusf.meisinger5832 Жыл бұрын
I did it now for Android 13, API 33 by the help of Intent.ActionCreateDocument and ActivityResultLauncher, works perfectly and on Windows platform I still use this ease of FileSaver
@daniblitz1029
@daniblitz1029 Жыл бұрын
does this work on Android? i was trying to save a power point presentation on android, but it says that it can't find the file. It's strange, because on windows machine it works. Does anyone know?
@marcosdalmolin357
@marcosdalmolin357 Жыл бұрын
In Android, it doesn't work; the window to save the file doesn't open for me.Does anyone know how to do it?. Thank you. I'm using MAUI Hybrid.
@trendytrailer2746
@trendytrailer2746 Жыл бұрын
Sir please make a video for social login like google, facebook and facebook for maui and xamarin
@Golden_games
@Golden_games Жыл бұрын
can this be used to save vidoes or music
@jfversluis
@jfversluis Жыл бұрын
Should be possible!
@Golden_games
@Golden_games Жыл бұрын
@@jfversluis great I will give it a try
@cesarcarvajal9483
@cesarcarvajal9483 Жыл бұрын
Do I need to validate EXTERNAL_STORAGE in my permissions?
@jfversluis
@jfversluis Жыл бұрын
If you want to save there then yes
@haha-hk9tx
@haha-hk9tx Жыл бұрын
This doesn't work on android 13 due to the WRITE_EXTERNAL_STORAGE permission no longer existing. Will there be any fix?
@haha-hk9tx
@haha-hk9tx Жыл бұрын
*On .NET 7
@jfversluis
@jfversluis Жыл бұрын
If you think there is a potential bug look on the repo if it’s reported already or open a new issue
@ghalaii2013
@ghalaii2013 Жыл бұрын
HI.. Installation of CommunityToolkit.Maui on existing solution failed, any clue??
@jfversluis
@jfversluis Жыл бұрын
Not without any details. I’m still not a mind reader 😔
@ghalaii2013
@ghalaii2013 Жыл бұрын
@@jfversluis I am following the steps to install the CommunityToolkit.Maui package, installation process finishes normally, but when I check the installed packages it is not there... no more details to provide
@DasgoodWernerdk
@DasgoodWernerdk Жыл бұрын
@@ghalaii2013 check the version of your Project Net Framework and the dependency of the Toolkit Nuget package. You need to be on the same versions.
@ChristopherMcDaniel-gv8pw
@ChristopherMcDaniel-gv8pw Жыл бұрын
I found something strange using this. When I try to write to a file that already exists, instead of completely erasing the file contents(as you would expect with a typical write operation), it actually only overwrites the first x number of bits. Example, if I initially wrote "Hello World! My Name is Chad!" with FileSaver, and then I wrote "I am using MAUI" to the same file, I would get this: I am using MAUI Name is Chad! As if it is only overwriting the first x bits for the length of the new file contents. Is this expected behavior or is this an issue?
@jfversluis
@jfversluis Жыл бұрын
Oh that’s interesting. I wouldn’t think that is the intended behavior. Could you please have a look of there is an issue on the repo describing this or otherwise open one?
@chezchezchezchez
@chezchezchezchez Жыл бұрын
What did you find out, my friend?
@ChristopherMcDaniel-gv8pw
@ChristopherMcDaniel-gv8pw Жыл бұрын
@@chezchezchezchez Last I checked, the issue was still being fixed. I haven't seen updates in a while. There was a GitHub thread pertaining to the issue, so maybe it will be addressed soon!
@babyj98
@babyj98 Жыл бұрын
Gerald, is it possible to save a pdf as well by any chance?
@jfversluis
@jfversluis Жыл бұрын
Sure as long as you have the contents of said PDF as a byte array you can save it
@babyj98
@babyj98 Жыл бұрын
@@jfversluis Is that documented somewhere by any chance?
@jfversluis
@jfversluis Жыл бұрын
Not that I know off
@babyj98
@babyj98 Жыл бұрын
@@jfversluis OK because I'm getting a error to where it makes the file but it says "can't open the file, something went wrong". I'll keep toying with it though thank you good sir.
@cesarcarvajal9483
@cesarcarvajal9483 Жыл бұрын
@@babyj98 you succeeded? I manage to save the document but when I open my file it tells me that it is not a pdf
@ceramicellasy3392
@ceramicellasy3392 Жыл бұрын
hello i cant save any image by filesaver
@jfversluis
@jfversluis Жыл бұрын
If you think there is a bug, Make sure to report it on the repository with details like a code or ideally a reproduction and any error messages you see
@ceramicellasy3392
@ceramicellasy3392 Жыл бұрын
@@jfversluis if i can ask you when i used drag and drop with image from stream i had exaptation you cant access file close
@fitrihalim9323
@fitrihalim9323 Жыл бұрын
I see it is not yet supported on .Net 6 :(
@jfversluis
@jfversluis Жыл бұрын
That is correct! .NET 7 and up
@swetajaiswal8383
@swetajaiswal8383 Жыл бұрын
Then how we do that in .net 6
@markusf.meisinger5832
@markusf.meisinger5832 Жыл бұрын
It even does not work on .NET 7 Android 13 API 33 :(
@QaysarboyUnamasov
@QaysarboyUnamasov Жыл бұрын
Really so easy.
@jfversluis
@jfversluis Жыл бұрын
Just how I like it!
Localization in .NET MAUI - Adding Multi-Language to Your Apps
24:17
Gerald Versluis
Рет қаралды 18 М.
Effective Alerts with Snackbar & Toast with .NET MAUI
15:39
Gerald Versluis
Рет қаралды 12 М.
How Strong is Tin Foil? 💪
00:25
Brianna
Рет қаралды 70 МЛН
ТЫ В ДЕТСТВЕ КОГДА ВЫПАЛ ЗУБ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 3,7 МЛН
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 75 МЛН
Triple kill😹
00:18
GG Animation
Рет қаралды 18 МЛН
Use .NET MAUI FilePicker to Pick PDFs, Images, Videos and More!
15:24
Gerald Versluis
Рет қаралды 20 М.
Is There Hope For .NET MAUI?
7:10
SingletonSean
Рет қаралды 30 М.
Take Pictures in Your App with CameraView for .NET MAUI
19:05
Gerald Versluis
Рет қаралды 7 М.
Highly Customizable Popups for .NET MAUI with Mopups
18:20
Gerald Versluis
Рет қаралды 32 М.
Adding Fingerprint Or Face Recognition To Your .NET MAUI App
18:00
Gerald Versluis
Рет қаралды 8 М.
3 Ways Combine .NET MAUI and .NET MAUI Blazor Hybrid
24:05
Gerald Versluis
Рет қаралды 29 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 249 М.
Check and Request Permissions in .NET MAUI
19:48
James Montemagno
Рет қаралды 25 М.
Accessing Native Platform APIs in .NET MAUI
23:51
James Montemagno
Рет қаралды 18 М.
Easily Record Audio with .NET MAUI and Plugin.Maui.Audio
13:26
Gerald Versluis
Рет қаралды 4,4 М.
How Strong is Tin Foil? 💪
00:25
Brianna
Рет қаралды 70 МЛН