I am working on an music application and after long testing I have came to the conclusion that for the firs run I have to Load in the XAP File the Levels Data instead of downloading it from a web service because it is faster and not so time consuming.
My question is if someone knows a method to read the file listing inside an application folder.
I have written a method that copies the data from one folder to the LocalStorage of the application (IsolatedStorage) and all I need is a way to read the content of the folder.
I have to mention that this is my first app for windows phone.
If the file is in the application folder - which means it is packaged up in the xap - you should be able to get the file using the Application.GetRourceStream like I've seen with apps that have local databases they package, but want to copy over to Isolated Storage after install.
Here's an example (from this page http://msdn.microsoft.com/en-us/library/hh202860(v=vs.92).aspx):
Stream str = Application.GetResourceStream(new Uri("appdata:/MyReferenceDB.sdf", UriKind.Relative)).Stream;
appdata: is what tells it to look in the application directory. Only other option is isostore:
So you have already copied the file from your xap resources to Isolated Storage, and you want to read the file back out of Isolated Storage? (Is there a reason you can't just load the data out of the xap, without copying it to Isolated Storage?)
Try this tutorial on files and Isolated Storage: http://www.windowsphonegeek.com/tips/all-about-wp7-isolated-storage-read-and-save-text-files (I recommend reading the whole thing, but I linked specifically to a page on creating and reading text files).
This question contains code for listing the files in your isolated storage, if you can't just hardcode your filename:
windows phone 7 File Listing IsolatedStorage
Related
Has anyone successfully used expansion files with appcelerator? I have found the module that is supposed to let us work with them, however I am running into the problem of the .obb file being downloaded directly from the play store and then being downloaded again with the module. Aside from that I can't seem to get access to any of the files contained within the .obb using the module.
I have heard all of the woes of having a big app, so please don't just tell me to make a smaller app, my client has a large "library" that they want installed directly on the app. It consists of html files that call javascript files and images through relative paths.
Are expansion files even the way to go with this? Should I simply zip up my files and download them after, unpack them, and access them using the file system? I am just looking for a way to get these large files onto the device and access them as if they were in the resources directory of the app.
Any help would be appreciated. thanks!
I have an app that needs over 300 PNG images and text files (to populate a database with) and could not get the app small enough to put up on the Play Store. What I ended up doing was create a barebones app (enough to get the user started) then I download the files on start up. I didn't mess with zipping everything (the data is constantly being updated), but if the information you have is pretty static, you could zip it. Once the download successfully finishes and installs the data, it sets an app property (Ti.App.Properties.setInt) 0 is never ran, 1 is partial download and 2 is download is installed (you can do this however you want, but that's what I did).
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)
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.
This guide shows how to deploy a COM object consisting of a single .dll file to a Windows Azure role using the start-up task mechanism.
Now I have a COM object that depends on several hundred other files - .dll files (I build them myself as well) and some binary data required for its operation that need to be deployed as a directory tree. Including that into the role project (as it is done for the single file in the guide) seems rather dumb - those files don't belong to the role functionality, instead the role just depends on the COM object.
How do I deploy a huge subtree containing the COM object and whatever it depends on onto Windows Azure most conveniently?
One popular technique is to store those files in blob storage. Two ways to do this:
Create a container for your DLL and dependent files, and store each file in its own blob.
Create a zip file of your DLL and dependency tree, and store that zip in a single blob
With an elevated startup task, you can copy down the file(s) and install your COM component.
Option #2 will likely result in a quicker bootup time, since it's a single copy, and it will have less storage transactions. You'll just need to bundle a zip application (or store that in a separate blob.
Nate Totten built a multi-tenant web role for Windows Azure, and the technique he uses for deploying a website involves option #2 above (although not as a startup task). I suggest looking at that project to see how the zip file is copied to local storage and unzipped.
EDIT: One more option is to look at AzureRunMe, an open source tool for unzipping and launching apps in a Windows Azure role.
If the files are going to change independently of the change process on the role, then I would agree with David's suggestions - I would put them all in a zip in Blob Storage and then use a startup task to download and install the files.
However, if the files are not going to change independently of the files in the role, then I would package the files in a .zip and then run a startup process to unzip and install those files from the role. One of the advantages of this approach is that the project is very straight-forward to deploy and version in "devops" - it doesn't have any dependencies on Blob storage.
One final option is that you could also put the DLLs in an Azure Drive - you could mount that drive and install the COM object from that drive during role startup.
Hi everyone
I would like to know if it's possible to deploy my app assets directly to Isolated Storage once the app get deployed.
I'm currently extracting them from code but this make the app's first launch too slow and it will be declined once it's submitted to the marketplace.
I'm wondering if there is a nice trick to make the process faster
Thanks
There's no way to automatically deploy to IsolatedStorage on app installation.
There are a few things you can do to try and avoid a delay on first start up though:
Refer to files directly in the XAP where possible.
Split the assets into multiple dlls so that only those needed are loaded into memory.
Load content to IS in the background and prioritize this so that the resources are loaded as needed.
You should not need to load image or video files into IS just to view them.
You should only need to copy the XML files if they're going to be updated. If you just want to read some data this doesn't need to be done. Also, if the XML files just hold initial data/state this could be loaded from the assembly directed and only saved to IS when first persisted.
in order to test my WP7 application with the emulator, I have to read a text file with a large input.
I have some problem to read it and to use the isolate storage.
More in details, the application is not able to read the file from my local disk.
How can i put the txt file into isolate storage?
Many thanks
Justin Angel has a blog post showing how to automate the emulator (for testing purposes) and it also includes details of how to copy files directly to the isolated storage for an app:
http://justinangel.net/WindowsPhone7EmulatorAutomation
See this question:
Open a project file in phone7
I give an example of how to access a file (resource) from your project and also how to copy that resource to isolated storage and access it as needed.
A simple way to test this would be to package the file in the XAP. If you don't need to modify the file while your app is running you can leave it there and just read it. Alternatively you can load it down to isolated storage at a convenient time while your app is running.