Studyxnet / FilePicker-Plugin-for-Xamarin-and-Windows

FilePicker Plugin for Xamarin and Windows
MIT License
74 stars 52 forks source link

Works fine but can't get file #38

Open cgarzacastelec opened 7 years ago

cgarzacastelec commented 7 years ago

I'm using the NUGet version 1.1.0 and I can use the file picker and it works fine but when I get a file the byte array is empty and the file name is only the name of the file without the path.

If only I could get the file's full path it would be great, from there I could get the byte array. I am doing something wrong? my code is like this:

var crossFilePicker = Plugin.FilePicker.CrossFilePicker.Current;

var myTask = await crossFilePicker.PickFile(); if (!string.IsNullOrEmpty(myTask.FileName)) { myTask.FileName.ToString();

foreach (byte b in myTask.DataArray)
     b.ToString();

}

cgarzacastelec commented 7 years ago

Also if you use the back button it won't let you pick andother file because "Only one operation can be active at a time"

ShahriatHossain commented 7 years ago

@cgarzacastelec this invalid operation already has been fixed on current repository and to use this current repository just download and build the project and replace dll files with your existing dll of this plugin. I think your problem will be solved. Because it also solved my same problem.

neptunecentury commented 7 years ago

The problem with the invalid operation is resolved in current repo, but for iOS, the document path and DataArray are null still.

cgarzacastelec commented 7 years ago

Thanks for your replies, I downloaded the latest from the current repository but now I have this error

        Plugin.FilePicker.Abstractions.FileData myData = null;
        try
        {
            var crossFilePicker = Plugin.FilePicker.CrossFilePicker.Current;
            myData = await crossFilePicker.PickFile();
            if (!string.IsNullOrEmpty(myData.FilePath)) //The file path, but is all wrong "document/8BBF-19D9:test.txt"
            {
                foreach (byte b in myData.DataArray) //DirectoryNotFound exception found when trying to get data array
                    b.ToString();
            }
        }
        catch (InvalidOperationException ex)
        {
            ex.ToString(); //"No longer happens but now we have... "
        }
        catch (DirectoryNotFoundException ex)
        {
            ex.ToString(); //... could not find a part of the path "document/8BBF-19D9:test.txt"
        }

I will be checking to code to see if I can fix it, thanks again

cgarzacastelec commented 7 years ago

Checking the code I found in IOUtil.class a TODO to handle non-primary volumes... adding the exact same code "return Android.OS.Environment.ExternalStorageDirectory + "/" + split [1];" if it is not "primary" gives me the right path of the file, anyone knows what "document/8BBF-19D9" stands for and why it isn't "primary" as the unaltered code?

Lavanya-pasupuleti commented 7 years ago

Thanks for the plugin and valuable info.It is working fine in android and windows, but facing the same issue in iOS platform.The document path and DataArray are null.Can any one suggest me the solution or work around for this issue.

Thanks in advance

neptunecentury commented 7 years ago

Hi, I followed the procedure here and it worked for me: https://github.com/Studyxnet/FilePicker-Plugin-for-Xamarin-and-Windows/issues/30

You'll have to download the repo and make the code changes described in the comments until a pull request is made and accepted for it.

Lavanya-pasupuleti commented 7 years ago

@neptunecentury Thank you so much.I followed the procedure its working.

mayur2871 commented 7 years ago

@cgarzacastelec @ShahriatHossain @neptunecentury @keannan5390 i am getting same issue in ios please help me exception thrown is :=" could not find a part of the path"

iupchris10 commented 7 years ago

@mayur2871 I was having the same problem as you and I replaced File.OpenRead in FilePickerImplementation.cs with this:

tcs?.SetResult(new FileData(e.FilePath, e.FileName, () => { var url = new Foundation.NSUrl(e.FilePath); return new FileStream(url.Path, FileMode.Open, FileAccess.Read); }) );

Hope this helps some people out. File.OpenRead didn't work for me when fetching file from iCloud drive. I think the key may be converting first to NSUrl.

SatanEnglish commented 7 years ago

@iupchris10 Thank you this works like a charm

Anyone know when this will be fixed on the nuget?

CarlosJeJe commented 6 years ago

Can someone give me the updated dll? please

ostilo commented 4 years ago

System.TypeLoadException: 'Could not load type of field 'Roemichs_Test_API.ImageDocs+d2:51' (5) due to: Could not resolve type with token 01000049 from typeref (expected class 'Plugin.FilePicker.Abstractions.FileData' in assembly 'Plugin.FilePicker, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null') assembly:Plugin.FilePicker, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null type:Plugin.FilePicker.Abstractions.FileData member:(null)'