开发者

Coping files from desktop to Windows Phone 7 Isolated Storage

I'm new to Phone 7 development.

I am trying to create an application the will load all the DLLs that I have created from a set location on the phone.

I have a basic menu application that will load all the DLLs I have created and display a list of then to the user using reflection to get an Icon out of the DLL and a description.

I have the following code to get all the dll but its not working

Dim cPlugins As New PluginCollection
        Dim temp As String = System.Reflection.Assembly.GetExecutingAssembly.GetName().CodeBase.ToString
        temp = System.Reflection.Assembly.GetExecutingAssembly.FullName
        Dim strFolder As String = System.IO.Path.GetDirectoryName(temp)
     开发者_如何学JAVA   strFolder = System.IO.Path.Combine(strFolder, "DLLS")

        For Each strFile As String In System.IO.Directory.GetFiles(strFolder, "*.dll")
            cPlugins.Add(New Plugin(strFile))
        Next

The above code doesn't work and keeps returning a file not found error.

Any help please?


To retrieve the DLLs as resources you'll need to add them as embedded resources (build action) in the projet/XAP file.

This will not require you to copy them to isolated storage.

If you were copying them to isolated storage then you could put htem there with isolated storage explorer but this would only work for testing. For the live app you'd need to include them in the XAP and then copy them to isolated storage. As you don't neeed them in isolated storage to open them as resources to extract images then it would be unnecessary effort.

If possible, you coudl make things easier for yourself in the WP7 app by not embedding the images inside a DLL but this may not be practical if you are using the same images/DLLs across projects on multiple platforms. Even if this is the case I'd recommend considering adding a build step to you WP7 app to extract the images once at design time. This will mean your app has to do less. It will therefore able to be faster, have less opportunity for bugs and provide a better experience to the user.

Edit:
The issue is the way you are trying to query the files in IsolatedStorage. There is no need to calculate the actual path of your isolated storage location. Instead you should use the IsolatedStorageFile.GetFileNames Method. You'll use it like:

Using store As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
    .... store.GetFileNames("/DLLS/*.dll")
End Using


The property Codebase isn't supported in Silverilght on the Phone. (See http://msdn.microsoft.com/en-us/library/system.reflection.assembly(v=VS.95).aspx) but you don't need to use this method to find the isolated storage location. Use the IsolatedStorageFile class instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜