文件下载并在本地保存 [英] File download and save locally
问题描述
大家好,
我将图片保存到我的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屋!