1) Do not use Directory.CreateDirectory on Windows Phone. Instead, since you are working with isolated storage, you need to use:
var file = IsolatedStorageFile.GetUserStoreForApplication(); file.CreateDirectory("myDirectory");
2) Downloading files can be done through WebClient as follows:
WebClient client = new WebClient(); client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted); client.OpenReadAsync(new Uri("your_URL")); void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { var file = IsolatedStorageFile.GetUserStoreForApplication(); using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("file.epub", System.IO.FileMode.Create, file)) { byte[] buffer = new byte[1024]; while (e.Result.Read(buffer, 0, buffer.Length) > 0) { stream.Write(buffer, 0, buffer.Length); } } }
Creating a directory in this case is optional. If you need to save the file in a subfolder structure, you can also set the file path to something like /Folder/NewFolder/file.epub .
3) To list files in isolated storage, you can use:
var file = IsolatedStorageFile.GetUserStoreForApplication(); file.GetFileNames();
This is if the files are in the root directory of IsoStore. If they are inside the directory, you will need to install the search template and pass it to GetFileNames - including the folder name and file type. For each individual file, you can use this template:
DIRECTORY_NAME\*.*
source share