locations to save files which can be accessed on app - c#

I want to supply a bunch of files with my Windows Phone 8.1 app which are necessary for running the application. I searched on the net and found that this page. But I don't know which place in particular is the ApplicationData.Current folder. What I want is the following:-
Can I create a folder called Resources or use the existing Assets folder in my Project tree and save the files in there.
If yes, then how can I access that folder from within my App i.e. how can I open and close files in that Directory(relative or absolute addressing format to be used)? If you can provide a one or two line code for this, it would be great.
Do I have to use the ReadTextAsync method to read the entire text of the file into a string or are there any other methods.(The System.IO.File.ReadAllText() method is not accessible when creating Windows 8.1 Phone app).
Thanks in advance.

Your App is installed on SD or Phone, depending on user Settings on the Phone. You can't normally access those files eg. by browsing files while Phone is connected to computer - the apps are Isolated.
Depending on your App:
if it's 8.1 Silverlight then you will find all the information here at MSDN.
if it's 8.1 RunTime then take a look here.
Although you can't access files inside your App from outside the App, from WP8.1 you have access (read/write) to SD Card and other KnownFolders.
EDIT - you can also access your files by using Uri schemes.

Related

How to allow app user to select a folder location where in app documents can be saved

I have a xamarin.forms app, I would like to allow users of app (android/ iOS/ windows) to be able to select a folder location at the start of the app and all the app related documents should be saved in that particular folder.
For now when I try to build a simple app which reads a xml file from the folder I create and display data on a list-view. I browsed through the file manager in android to see where the file is located physically on android device, but could not find any folder with app name.
In simple words I want a folder on the device to be created, which will be selected by the user. And accessible from file manager.
The reason behind this requirement is, the app is going to record a mp3 file and save a recording to a selected folder. So whenever the user wants to change his mobile he can always copy the recording to the new mobile and not loose any of the recordings.
To be able to use any of the possibilities below you will have to write platform-specific code in Xamarin.Forms and then expose some interface that you can use back in your PCL project.
Android:-
There is a post Choose File Dialog on how to create a file dialog selector (with directory changer), although not in Xamarin.
You will want to point the starting location to a shared folder of some kind.
There is a Xamarin tutorial here that walks you through how to create a simple file browser.
iOS:-
For iOS you may be interested in the iOS Document Picker View Controller, here.
There is an extensive tutorial of how to complete this using Xamarin here.
(pictures are from Xamarin website)

Windows Phone 8 file sharing

I have created an app that makes use of file types that are not standard to Windows Phone and I have registered my app to these extensions and they can be opened in my app perfectly from example the email client.
My application can modify the file as well as generate completely different ones. I then have an internal file manager page where users can delete files and choose to open then.
My problem now is that I want the user to share these files via email, Bluetooth, tap+send(nfc), etc. with a menu pretty much like the you get in the gallery(photos) app on Windows Phone. Is this a standard function that I can somehow access, or is there another standard library or anything really that I can use to as quickly as possible implement file sharing?
There is a ShareMediaTask but it is intended for sharing media files on any kind of files, so you need to implement everything by yourself.

Fileupload into WP7 application

I just have a "short" Question. I did a lot of research the last few hours and found out, that a Wp7 application has access to his own directory and the IsolatedStorage. So if I want to work with a file in my application I either have to load it into the project using the Solutionexplorer in VS, or create a file manually by code, load it into the Isolated Storage and then read out of it.
So i come to the result that it isnt possible to load a specific file, which is in an unknown directory or folder and has an unknown name from my mobile Phone (or WP7 emulator) into the App directly, right? Because there is no browsing feature or something like e.g. in the ASP.NET Webform,the FileUploadControl.
Is my understanding correct or do I miss something?
you cannot access anything that is on the phone (except music and photo lib etc) other than whats included with the app and its isolated storage area.
you can't browse the local device like you can on windows. however you can download files from the net.

How to Play Video File On D Drive In WinRT?

Using XAML C# in Windows "Metro" Apps how do I go about playing a certain video file. Examples:
D:\video1.wmv
\\MEDIAPC\video2.wmv
The only way I managed to get this working so far is by using FilePicker, but I don't want to use this as I already have a list of files to play.
I have tried to use GetFileFromPathAsync but I keep getting permission / access issues
await StorageFile.GetFileFromPathAsync(#"D:\video1.wmv");
Apologies if this has been answered I just couldn't find an answer that fits my problem.
If your D:\ drive is a non-network resource try adding the Removable storage application capability. This can be accomplished by double-clicking on the Package.appxmanifest and navigating to the Capabilities tab. By default your application (assuming it is a Windows Store app) only has access to local files packaged with your app or files stored in local/roaming/temp folders (usually reserved for Application state).
If your data is stored on a Network resource that requires authentication you will want to enable the Enterprise Authentication capability.
You may also want to fiddle with the Home and Work Networks for the \MEDIAPC\ files if you aren't accessing resources that require network authentication.
Further Reads:
Accessing data and files
How to load data from files
App Capabilities Overview

How to browse the content of File in window phone 7?

I am new to the windows phone 7 development world. I am developing an application in window phone 7. In window mobile application (smart device application) we can browse the content of the mobile device by selecting the tools -> Device Emulator Manager -> slecting the emulator & then after clicking the cradle we can browse the content of the mobile device. I want to know how to do this in windows phone 7 application ? I also want to know how to programatically access the content of the Window Phone 7 ? (for e.g I want to open the screen which we will be opened after clicking the upload button in asp.net. In that screen we can navigate between the folder structure of the computer. In such way I want to open the screen for window phone 7) Because I am developing an application in which I want the images from the existing mobile device. So I want to browse the content of the mobile device so that I can select the particular image from the existing content of the mobile device & after that I will dynamically add these images to the images folder of my application. Can you please provide me any code or link through which I can resolve the above issue? If anyone know anything that will also help me a lot. Please share anything whatever anyone knows.
Due to the security model of Windows Phone 7 and fact that applications are sandboxed means that it is not possible to create a file system browser on the device. You can only see files / the directory structure within IsolatedStorage and you must create these files yourself.
You can, however, use MediaLibrary.Pictures or the PhotoChooserTask to access the images stored on the device. These are the images youu'll see in the Pictures hub and, therefore are outside of the files you specifically put in IsolatedStorage.
You can only access the files/directories that are located in the Isolated Storage that is assigned to your application, and you can get a list of those via GetDirectoryNames (for folders) and GetFileNames (for files). You will have to implement a custom listing mechanism since there is no default storage browser component.

Categories

Resources