文件下载并在本地保存 [英] File download and save locally

查看:83
本文介绍了文件下载并在本地保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我将图片保存到我的Windows手机应用程序的本地文件夹中

 var localFolder = ApplicationData.Current.LocalFolder 

var photoFile = localFolder.CreateFileAsync((" mani"),
CreationCollisionOption.ReplaceExisting);

我保存文件没有扩展名,同时出于安全原因保存到本地,并避免其他应用程序查看。


当我搜索谷歌时我得到了这个api用于文件的启动默认应用程序

 Windows.System.Launcher.LaunchFileAsync(photoFile); 

但是我的本地文件没有扩展所以我无法使用此Api用于默认应用程序启动。你能指导我这个
的替代解决方案


谢谢,


Manikandan。


解决方案

Hi Manikandan Selvaraj22,


在调用LaunchFileAsync之前将您的文件扩展名更改为正确的类型,并在启动后更改回来。

 var file = await localFolder.GetFileAsync(" mani"); 

FileInfo f = new FileInfo(file.Path);

f.MoveTo(Path.ChangeExtension(file.Path," .png"));

等待Windows.System.Launcher.LaunchFileAsync(file);

f.MoveTo(Path.ChangeExtension(file.Path,""));


Hi All,

I m saving image into local folder for my windows phone application

var localFolder = ApplicationData.Current.LocalFolder 

var photoFile = localFolder.CreateFileAsync(("mani"),
            CreationCollisionOption.ReplaceExisting);

I m saving file without extension while save into locally for security reason and avoid other apps to view.

When i search google i got this api for launch default apps for file

Windows.System.Launcher.LaunchFileAsync(photoFile);

But my local file dont have extension so i can't use this Api for default application launch. Could you please guide me alternative solution for this

Thanks,

Manikandan.

解决方案

Hi Manikandan Selvaraj22,

before calling LaunchFileAsync change your file extension to correct type and after Launch change back.

var file = await localFolder.GetFileAsync("mani");

FileInfo f = new FileInfo(file.Path);

f.MoveTo(Path.ChangeExtension(file.Path, ".png"));

await Windows.System.Launcher.LaunchFileAsync(file);

f.MoveTo(Path.ChangeExtension(file.Path, " "));


这篇关于文件下载并在本地保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆