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

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ม.ค. 2025

ความคิดเห็น • 93

  • @jfversluis
    @jfversluis  ปีที่แล้ว +4

    Saving files goes perfectly with picking a folder, don't you think? Good thing I have a video on FolderPicker as well 📂 th-cam.com/video/lOzAWGsWKf4/w-d-xo.html
    Or you just enjoy watching my videos? Then I have a playlist about .NET MAUI in general for you, right here 👉 th-cam.com/video/lOzAWGsWKf4/w-d-xo.html

  • @acodersjourney
    @acodersjourney ปีที่แล้ว

    A big shoutout for the incredible work you do in simplifying coding challenges. Your videos have been a lifesaver!

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      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  ปีที่แล้ว +1

      Haha that is great! Hope this was helpful then!

  • @berniemueller2827
    @berniemueller2827 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

    It really got easier! thank you amazing channel

    • @jfversluis
      @jfversluis  ปีที่แล้ว +3

      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

  • @flrcml69
    @flrcml69 6 หลายเดือนก่อน

    Hi @Gerald Versluis How to save a file .db with FileSaver in a chois folder with FolderPicker?

  • @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!

  • @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

  • @jewersp
    @jewersp ปีที่แล้ว

    This is awesome, Gerald. It would be great to see how this works on the other platforms.

    • @jfversluis
      @jfversluis  ปีที่แล้ว +1

      It should be more or less the same, go try it out ;)

  • @earthlingthings
    @earthlingthings 5 หลายเดือนก่อน

    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  5 หลายเดือนก่อน +1

      Wrap it in some kind of service class and maybe use dependency injection

  • @earthlingthings
    @earthlingthings 2 หลายเดือนก่อน

    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  2 หลายเดือนก่อน

      Make sure to report it to the repo!

  • @TechnoNewsUpdates
    @TechnoNewsUpdates 9 หลายเดือนก่อน

    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.

  • @ebrahimmehri
    @ebrahimmehri 11 หลายเดือนก่อน

    Excellent! Thank you.

  • @AthiraRNAIR-gr7gc
    @AthiraRNAIR-gr7gc 10 หลายเดือนก่อน

    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 😊

  • @sandeepsirohi8434
    @sandeepsirohi8434 3 หลายเดือนก่อน

    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)?

  • @GianfrancoTronu
    @GianfrancoTronu ปีที่แล้ว

    Thank You very much indeed for this video !

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      You’re very welcome!

  • @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.

  • @anandshindey
    @anandshindey ปีที่แล้ว

    very nice, just what I needed. Thanks.

    • @jfversluis
      @jfversluis  ปีที่แล้ว +1

      Thanks great, good luck!

  • @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?

  • @abelanil
    @abelanil ปีที่แล้ว

    As you say, is amazing. Thanks

  • @MatiHalek
    @MatiHalek ปีที่แล้ว

    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 ปีที่แล้ว

      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

  • @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!

  • @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

  • @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.

  • @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  ปีที่แล้ว +1

      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!!

  • @surdz
    @surdz ปีที่แล้ว

    can i implement this in maui blazor?

  • @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

  • @davidsutton6863
    @davidsutton6863 ปีที่แล้ว

    Can you show us how to store a file without the user dialog please Gerald?

    • @jfversluis
      @jfversluis  ปีที่แล้ว +1

      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  ปีที่แล้ว +1

      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!

  • @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

  • @babyj98
    @babyj98 ปีที่แล้ว

    Gerald, is it possible to save a pdf as well by any chance?

    • @jfversluis
      @jfversluis  ปีที่แล้ว +1

      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  ปีที่แล้ว +1

      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 :(

  • @cesarcarvajal9483
    @cesarcarvajal9483 ปีที่แล้ว

    Do I need to validate EXTERNAL_STORAGE in my permissions?

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      If you want to save there then yes

  • @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

  • @trendytrailer2746
    @trendytrailer2746 ปีที่แล้ว

    Sir please make a video for social login like google, facebook and facebook for maui and xamarin

  • @QaysarboyUnamasov
    @QaysarboyUnamasov ปีที่แล้ว

    Really so easy.

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      Just how I like it!