subbu
subbu

Reputation: 3299

Re : Saving downloaded Files into MyDocuments

I have a doubt from a silverlight application we can access MyDocuments. I am creating an Application which will download a set of files from a remote server . Is it possible to save these file in MyDocuments instead of Isolated Storage. I am using Silverlight 4.0 . Can any one give me Sample codes for it.

Upvotes: 3

Views: 1147

Answers (2)

AnthonyWJones
AnthonyWJones

Reputation: 189505

In order to acheive that you need to use Silverlight 4 and specify that is should get elevated privileges when install as an Out-of-browser application. When running as an OOB the app will have access to the users Documents folder.

In all other cases you will need to use the SaveFileDialog where the user can explictly specify where to save the file.

Edit code example:-

if (Application.Current.HasElevatedPermissions)
{
   string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
   path = Combine.Path(path, "MySaveFile.dat");
   using (var filestream = File.OpenWrite(path))
   {
        // pump your input stream in to the filestream using standard Stream methods
   }
}

Upvotes: 2

Robban
Robban

Reputation: 6802

No Isolated storage is currently the only option.

Upvotes: 0

Related Questions