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

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 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 📂 ruclips.net/video/lOzAWGsWKf4/видео.html
    Or you just enjoy watching my videos? Then I have a playlist about .NET MAUI in general for you, right here 👉 ruclips.net/video/lOzAWGsWKf4/видео.html

  • @acodersjourney
    @acodersjourney 9 месяцев назад

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

    • @jfversluis
      @jfversluis  9 месяцев назад

      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!

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

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

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

  • @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  Год назад +1

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

  • @flrcml69
    @flrcml69 3 месяца назад

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

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

  • @tahirkhan466
    @tahirkhan466 11 месяцев назад

    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

  • @GianfrancoTronu
    @GianfrancoTronu Год назад

    Thank You very much indeed for this video !

  • @earthlingthings
    @earthlingthings 5 дней назад

    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  3 дня назад

      Make sure to report it to the repo!

  • @earthlingthings
    @earthlingthings 3 месяца назад

    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  3 месяца назад +1

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

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

  • @anandshindey
    @anandshindey Год назад

    very nice, just what I needed. Thanks.

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

  • @AthiraRNAIR-gr7gc
    @AthiraRNAIR-gr7gc 8 месяцев назад

    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 😊

  • @abelanil
    @abelanil Год назад

    As you say, is amazing. Thanks

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

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

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

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

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

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

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

  • @surdz
    @surdz Год назад

    can i implement this in maui blazor?

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

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

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

  • @cesarcarvajal9483
    @cesarcarvajal9483 Год назад

    Do I need to validate EXTERNAL_STORAGE in my permissions?

    • @jfversluis
      @jfversluis  Год назад

      If you want to save there then yes

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

  • @Golden_games
    @Golden_games Год назад

    can this be used to save vidoes or music

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

  • @trendytrailer2746
    @trendytrailer2746 Год назад

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

  • @fitrihalim9323
    @fitrihalim9323 Год назад

    I see it is not yet supported on .Net 6 :(

  • @QaysarboyUnamasov
    @QaysarboyUnamasov Год назад

    Really so easy.