Windows Phone 8.0 - Access phone's local storage - c#

Is there any API that enables me to access the phone's local storage files and folders ? I want to implement a file picker that displays the folders and files hierarchy just like they are in folder explorer:
Microsoft has released a free app called "Files" that does exactly what I want and more. Is it a special case or its possible for any developer?
Note: Im programming a WP8.0 app and not WP8.1. File Picker sample won't work for me! :)

There is no API in WP8 to list all the files in storage. In WP8 you can only access Audio and image files.
For more details refer this.

Related

File saving issue Windows phone 8.1

I am facing the following issue while performing the save operation on a windows 8.1 phone
a. Let us assume there is a a file named test1.doc is downloaded to a default location in the sdcard. SDCARD - Testfolder
b. We try to edit/open the file using the office 365 present in the phone and try to save it. It does not save it in the same location i.e. TestFolder.
c. It prompts the user to save in the file in the default folder present in phone for eg in the above case since it is a .doc it saves in Documents folder.
Based on the file extension, it will try to save them in the respective default location i.e. mp3 will be saved under music, .jpg or png will be in picture, .mp4 under videos and .doc,.xls,.txt, ppt under documents.
Pl. refer to the below link
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn639127.aspx
d. And during save it also modifies the file name by appending (1) to the file. User is also given the option to modify the file name before saving.
Where on the tab and desktop it is allowing us to do the save on the same location.
I would like to know if it is a know limitation on the windows phone or any thing needs to be done to make the file save in the same location. Any input on this will be of great help.
That is the platform norm (I am not calling it as "limitation"). Every app has access to its own IsolatedStorage and media libraries depending on the access requested in manifest.

GUI for video files in the Windows Phone Isolated Storage

I'm currently working on a Windows Phone (8.0) application that can record video's. I want to save multiple video files in the Isolated Storage, but i can't find a way to view these saved files in a nice graphical interface with thumnails and information about length or size (much like the Windows Phone Camera Roll).
Could someone help me with this? There doesnt seem to be a lot of documentation on viewing the video files from the isolated storage.
Maybe it's something stupid, but i'm relatively new to developping for phones.
Thanks in advance!
1) I am not clear about your requirement but if you want see the Isolated Storage files in your machine you can use "Windows Phone Power Tools". For more info visit : http://msdn.microsoft.com/en-us/library/windows/apps/hh286408(v=vs.105).aspx
2) If you planning to make your own video gallary in Windows Phone app
Use AudioVideoCaptureDevice class to record videos and implement "PreviewFrameAvailable" event of it.
In that event, implement videoCaptureDevice.GetPreviewBufferArgb(argbPx) method.
For the size of video, when your read file from IsolatedStorage, you will get bytes array for data. That is the size of file. Covert it to Mb, Kb, etc format you want.

Copying video file from Project package to Isolated Storage during run-time

I require to play a short video in my WP8 application. Unfortunately, there is no API available for playback from MediaLibrary.
The only API I know of is as per this link:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394041(v=vs.105).aspx
The above method works only if the VideoFile is stored in Isolated Storage.
While I understand that I can upload files to Isolated Storage using some tools, I would rather prefer to package the Video file inside the xap, and then copy the file to Isolated Storage during run-time.
Can someone please guide me on copying a VideoFile included in Application project to Isolated Storage during run-time.
You can add a video as an app asset the same way as you add an image. Add video to your project and mark it as Content. The video will be packaged with the app in xap.
You accomplish this with the MediaElement control. Here is a great sample on how to use it. The basics is to add it to your xaml and set the source to a file that is has the build action set to content.
<MediaElement x:Name="VidoPlayer" Source="/Assests/MyVideo.wma" AutoPlay="True" Volume="1"/>
So as long as you have a file MyVideo.wma located in the Assests folder and the Build Action is set to Content, you're golden!

Writing files to an Android in C#

I am writing a Windows Forms application in C#, and I want to copy files from a directory on my C:\ drive into the "Computer\SPH-D710\Phone\Music" directory on my Android phone. That music path I just copied and pasted from Windows Explorer to this post, but C# does not recognize it as a valid directory, probably because there is no "C:\" or the like.
What is a C# command that can write a file to an Android?
It appears your phone is connected as a MTP device (media transfer protocol). It is not as simple as a file system access (USB mass storage). Read these series of blogs on how to do it, its not a simple file copy.
https://learn.microsoft.com/en-us/archive/blogs/dimeby8/sending-mtp-commands-through-wpd-part-1-without-a-data-phase
https://learn.microsoft.com/en-us/archive/blogs/dimeby8/sending-mtp-commands-through-wpd-part-2-data-to-the-device
https://learn.microsoft.com/en-us/archive/blogs/dimeby8/sending-mtp-commands-through-wpd-part-3-data-from-device
Beware you will be diving into some unmanaged code for this.
The .NET libraries used to store files won't really care where they are saving the file. Your Android device is seen as a USB storage device (as long as USB storage is turned on from the phone's point of view!). I recommend that you put some of your C# code up so that we can potentially spot an error in the routine that you are running to actually save the file to the phone.
As a quick example - your C# code will likely want to look something like this:
string filePath = #"G:\Music\MySong.mp3";
System.IO.File.WriteAllBytes(filePath, mp3FileContent);

WP7 -- finding isolatedStorage files on my computer

I am trying to use the C# class IsolatedStorageFile to write some data to a file in my app. This is using the simulator. I would like to look on my computer to see if it worked (i.e., look at the file in notepad). Where can I find that file?
The Isolated Storage is stored in the emulator, which is a virtual machine, and not directly on your harddrive. You'll have to code your own file viewer (e.g. from within your app, load the file from Isolated Storage and display the text using StreamReader).
I vaguely remember that the Mango toolkit (out in May) features an IsolatedStorage viewer built into the emulator, but I'm not sure what features it has.
You might be interested in this blog post. It explains how to export your file to your desktop.
You can download IsolatedStorageExplorer And use it to download file from IsolatedStorage to Computer.
Check out this Post and Answer given by Matt Lacey

Categories