PCLStorage icon indicating copy to clipboard operation
PCLStorage copied to clipboard

This is discontinued.

Open SuperJMN opened this issue 7 years ago • 22 comments

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

SuperJMN avatar Oct 04 '17 06:10 SuperJMN

Is there any other really good alternative for this plugin?

Szymaniuk avatar Oct 23 '17 11:10 Szymaniuk

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

SuperJMN avatar Oct 23 '17 13:10 SuperJMN

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?

Szymaniuk avatar Oct 23 '17 13:10 Szymaniuk

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.

xavier-rigau avatar Oct 23 '17 18:10 xavier-rigau

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 avatar Nov 06 '17 21:11 Binnette

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 avatar Nov 18 '17 15:11 Binnette

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

Binnette avatar Nov 18 '17 17:11 Binnette

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

xavier-rigau avatar Nov 19 '17 02:11 xavier-rigau

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

LanceMcCarthy avatar Jan 18 '18 21:01 LanceMcCarthy

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

charlesroddie avatar Feb 14 '18 01:02 charlesroddie

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

robintschroeder avatar Mar 06 '18 17:03 robintschroeder

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

charlesroddie avatar Mar 06 '18 17:03 charlesroddie

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

Szymaniuk avatar Mar 07 '18 08:03 Szymaniuk

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

ghuntley avatar Apr 04 '18 05:04 ghuntley

@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

dsplaisted avatar Apr 04 '18 17:04 dsplaisted

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

charlesroddie avatar Apr 04 '18 20:04 charlesroddie

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

Bobisback avatar Apr 17 '18 17:04 Bobisback

@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}");
    }
}

LanceMcCarthy avatar Apr 17 '18 22:04 LanceMcCarthy

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.

Bobisback avatar Apr 17 '18 22:04 Bobisback

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.

LanceMcCarthy avatar Apr 17 '18 22:04 LanceMcCarthy

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

charlesroddie avatar Apr 18 '18 05:04 charlesroddie

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

LanceMcCarthy avatar Apr 18 '18 22:04 LanceMcCarthy