开发者

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 on开发者_如何学运维e give me Sample codes for it.


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
   }
}


No Isolated storage is currently the only option.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜