PCLStorage icon indicating copy to clipboard operation
PCLStorage copied to clipboard

Need simple example of checking if a FIle Exists on Windows in a PCL Analyzer VSIX

Open paul1956 opened this issue 10 years ago • 6 comments

I think I need the code below

           Dim f As IFolder = Await FileSystem.Current.LocalStorage.GetFolderAsync(IO.Path.GetDirectoryName(context.Document.FilePath), context.CancellationToken)
            Dim r As ExistenceCheckResult = Await f.CheckExistsAsync(newFileName, context.CancellationToken)
            If r = ExistenceCheckResult.FileExists Then

but when I run it in the debugger I get this message on the first line

"This functionality is not implemented in the portable version of this assembly.  You should reference the PCLStorage NuGet package from your main application project in order to reference the platform-specific implementation."

What does this mean and how do I fix it? I don't need this in the VSIX project because it is not a PCL and the PCL project can't access the VSIX project.

paul1956 avatar Dec 20 '15 04:12 paul1956

PCL Storage uses the "bait and switch" pattern, so you do need to reference PCL storage from the VSIX even if you're not using it directly there.

dsplaisted avatar Dec 20 '15 19:12 dsplaisted

Sorry I am being dense but I think you are saying to get this to work all I have to do is add the PCLStorage NuGet package to the VSIX project in addition to the PCL project. Then when I run the code above it will just work. If that is correct I will close the issue.

paul1956 avatar Dec 20 '15 20:12 paul1956

Yes, try referencing the PCLStorage NuGet package from the VSIX project and let me know if that works. If not, perhaps VSIX projects work a little differently and you might have to manually include the right DLL.

dsplaisted avatar Dec 20 '15 20:12 dsplaisted

That did not work, the PCL project reference

...\packages\PCLStorage.1.0.2\lib\portable-net45+wp8+wpa81+win8+monoandroid+monotouch+Xamarin.iOS+Xamarin.Mac\PCLStorage.dll

image The copy in the VSIX is different.

...\packages\PCLStorage.1.0.2\lib\net45\PCLStorage.dll

image

paul1956 avatar Dec 21 '15 02:12 paul1956

The references are supposed to be different. That's how bait and switch works.

-----Original Message----- From: "Paul M Cohen" [email protected] Sent: ‎12/‎20/‎2015 6:33 PM To: "dsplaisted/PCLStorage" [email protected] Cc: "Daniel Plaisted" [email protected] Subject: Re: [PCLStorage] Need simple example of checking if a FIle Exists onWindows in a PCL Analyzer VSIX (#29)

That did not work, the PCL project reference ...\packages\PCLStorage.1.0.2\lib\portable-net45+wp8+wpa81+win8+monoandroid+monotouch+Xamarin.iOS+Xamarin.Mac\PCLStorage.dll

The copy in the VSIX is different. ...\packages\PCLStorage.1.0.2\lib\net45\PCLStorage.dll

— Reply to this email directly or view it on GitHub.

dsplaisted avatar Dec 21 '15 02:12 dsplaisted

But it doesn't work, no switching is going on.

paul1956 avatar Dec 21 '15 02:12 paul1956