dsplaisted / PCLStorage

PCL Storage - Portable Storage APIs
Microsoft Public License
305 stars 94 forks source link

This is discontinued. #66

Open SuperJMN opened 7 years ago

SuperJMN commented 7 years ago

You just have to take a look to see that this project isn't even maintained.

Szymaniuk commented 7 years ago

Is there any other really good alternative for this plugin?

SuperJMN commented 7 years ago

I don't really know. If someone can answer, please, do!

Szymaniuk commented 7 years ago

I really didn't have much issues with this plugin, except this one https://github.com/dsplaisted/PCLStorage/issues/14 but I'm worry about the future, and if something won't break in next XF/Android/iOS releases.

Anyone :P?

xavier-rigau commented 7 years ago

We had a lot of issues with PCLStorage and we submitted a few. The API is quite limited but workable.

Here is another one #61

I would be interested in a replacement too.

Binnette commented 7 years ago

I also think that this plugin is discontinued. This is a very bad news :cry: This plugin is still referenced as 'the' xamarin storage plugin in this page : https://github.com/xamarin/XamarinComponents

@antonioseric opened an issue here xamarin/XamarinComponents#27 He recommands this alternative plugin : https://github.com/PCLExt/PCLExt.FileStorage

Binnette commented 7 years ago

Hi, i fill a bug report to Xamarin. You can view and comment it here : https://bugzilla.xamarin.com/show_bug.cgi?id=60749

Binnette commented 7 years ago

Hi, if you want a .NET Standard Storage plugin, please vote here 👍 👍 👍 https://xamarin.uservoice.com/forums/144858-xamarin-platform-suggestions/suggestions/32307739-create-a-net-standard-storage-plugin-for-xamarin

xavier-rigau commented 7 years ago

Replace or update this plug in please. We desperately need one that is up-to-date and more convenient. Daniel @dsplaisted is no longer actively working on this one. It is workable but it has a few open issues and the interface is limited. I agree with @Binnette

LanceMcCarthy commented 6 years ago

Use System.IO, it's available on Android, iOS and UWP.

charlesroddie commented 6 years ago

@Binette System.IO is in .Net Standard 2.0.

robintschroeder commented 6 years ago

https://www.nuget.org/packages/PCLStorage.Standard/

charlesroddie commented 6 years ago

@robintschroeder That may be useful for projects that are on .Net Standard 1.x (e.g. needing to support Windows 8 store apps) but not needed for projects that can target .Net Standard 2.0. I migrated from PCLStorage to System.IO and while PCLStorage was an essential solution to a major problem at the time, it's much nicer to use System.IO.

Szymaniuk commented 6 years ago

I also completely get rid of PCLStorage and moved to pure System.IO with .NETStandard 2.0.

ghuntley commented 6 years ago

Howdy @robintschroeder I managed to get some 1:1 time with the maintainer whilst at mvpsummit. I now have admin privs on this github repo and admin privs on nuget to push new versions. Do you want to take over as maintainer (or at min raise a PR from your fork into this repo so that folks have a smoother upgrade path?)

dsplaisted commented 6 years ago

@ghuntley I think you still need to accept the invite to be a collaborator on the repo so I can mark you as an admin

charlesroddie commented 6 years ago

Is there any reason to keep this project going? What features does it add that are not in .Net Standard?

Bobisback commented 6 years ago

@charlesroddie or @Szymaniuk Are there any samples or examples of using System.IO in xamarin forms. Or any docs that explain migrating from PLC Storage to Ssytem.IO?

LanceMcCarthy commented 6 years ago

@Bobisback System.IO has a File object, which has a ton of helpful methods. I recommend reading this documentation, it's a great place to start.

image

Here's a simple example that will save text to a file, then reopen the file to verify that it was properly saved:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <Label x:Name="OutputLabel"
           LineBreakMode="CharacterWrap" />

    <Button Text="Save File"
            Clicked="Button_OnClicked"
            Grid.Row="1" />
</Grid>

UPDATED

private int writeNumber = 0;

private void Button_OnClicked(object sender, EventArgs e)
{
    try
    {
        var currentFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

        var fileName = "notes.txt";
        var filePath = Path.Combine(currentFolder, fileName);

        using (var fileStream = File.OpenWrite(filePath))
        using (var streamWriter = new StreamWriter(fileStream))
        {
            streamWriter.WriteLine($"Text writing {++writeNumber}");
        }

        using (var streamReader = File.OpenText(filePath))
        {
            OutputLabel.Text = streamReader.ReadToEnd();
        }
    }
    catch (Exception ex)
    {
        Debug.WriteLine($"Exception: {ex}");
    }
}
Bobisback commented 6 years ago

So Directory.GetCurrentDirectory() will reliably get the local storage directory of iOS and Android?

I guess this was probably my biggest concern, Is making sure that the files are being saved in a place that is considered legal by ios and android standards.

LanceMcCarthy commented 6 years ago

No, even though my above example works on iOS, it won't on UWP because the app doesn't have permissions to write to that folder (you'll get a System.UnauthorizedAccessException).

You would want to get the safe folder for each platform and use that. You can do this with a DependencyService, see Working With Files doc. You'll see that each platform is able to provide a folder that files get saved to.

charlesroddie commented 6 years ago

@Bobisback I am using Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

@LanceMcCarthy Also it's best to use Path.Combine since slashes go in different directions on different platforms.

LanceMcCarthy commented 6 years ago

Thanks @charlesroddie,

@Bobisback I updated my snippet.

Side Notes:

Environment.GetFolderPath and Environment.SpecialFolder are only available in .NET Standard 2.0. If you're using 1.4, you'll need to change project settings Target Framework version.

If you have a UWP project: To support .NET Standard 2.0, make sure your Min and TargetSDK version are at least Fall Creators Update (16299):

image

and your UWP project's Microsoft.NetCore.UniversalWindowsPlatform NuGet package is at least 6.0:

image