Use your Windows Phone as a USB storage device. You can build this on your own.
You probably always wanted to use your Windows Phone device as a USB storage device but never could. Well, this is solvable. There were a couple of hacks floating around, but I was curious to see if I can do it by myself. Well, I found a way to do it without third-party OS hacks and only with the help of a simple application built around the Microsoft.Smartdevice.Connectivity assembly.
I am not releasing the application itself at this point because there is more work to be done, but you can take a peek at what it looks like:
So how it works? I tried looking at physical locations in the phone filesystem that have unrestricted access. One of these locations is the folder where application data is stored (by the way, that is the place where all Isolated Storage content goes as well). The folder is \Applications\Data.
Usually, when an application is installed, there is also a folder that is designated to that application right inside the Data folder:
Instead, I decided to write directly in the data folder. The main reason for doing so is that I have full write access without interferring with any other application's storage.
First, I am getting the device I need:
DatastoreManager manager = new DatastoreManager(CultureInfo.CurrentCulture.LCID); Platform currentPlatform = (from p in manager.GetPlatforms() where p.Name == "Windows Phone 7" select p).First(); currentDevice = (from d in currentPlatform.GetDevices() where d.Name == cmbDevices.Text select d).First();
Here, currentDevice is an instance of Device. Once done, I can easily use the associated FileDeployer to write data to the device:
The first parameter is the local path on the desktop computer. The second one - the path to the file on the phone. Notice that I am also using a TEST folder inside the Data folder. This is an acceptable way of creating a new folder when you are copying new files to it.
As easy as that. If you want to receive content from the phone, you can go the other way around - swap the parameter order and use ReceiveFile.
There is no way you can enumerate files through the FileDeployer at the moment, so you will have to have an individual listing solution - for example, an XML file that keeps the list of subdirectories and directories (if outside an Isolated Storage folder).
Can I upload files to an app's isolated storage and why would I do that?
Yes, you can, as long as you follow the iso store path I mentioned above. The main benefit would be the ability to add and remove files. If you are placing content directly in the Data folder, you won't be able to remove it easily since there are no public methods to do it (there are workarounds).
When there is an associated application, you can always manage files present in the Isolated Storage through the application itself, even without the desktop client.