文件管理器 [英] file explorer

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

问题描述

hi


我正在尝试为Windows 10移动设备创建一个文件浏览器...


我想要获取文件和来自SD卡的目录并添加到列表框


然后点击每个项目(文件)用默认应用程序打开它...(比如打开图片照片应用)


但我无法启动文件


我找到了一个代码,但它只是打开资产中的文件......

 

string CountriesFile = @" Assets\1.jpg" ;;
StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFile file = await InstallationFolder.GetFileAsync(CountriesFile);
var success = await Launcher.LaunchFileAsync(file);

如何从以下地址打开文件?

@ "d:\\\\ b.jpg"


和另一个问题...

如何获得默认应用图标? (比如mp3文件上的凹槽音乐图标)


请帮帮我


tnx很多

解决方案

Hi Milad Poursaleh


>>如何从以下地址打开文件?


应用程序没有' t可以直接访问d:\。您可以使用fileopenpicker来获取StorageFile,而不是通过路径创建文件。 


UWP应用程序具有有限的文件访问权限,他们可以默认访问某些文件系统位置,如应用程序数据位置
和应用程序安装目录。应用还可以通过文件选择器或通过声明功能访问其他位置。


您可以从
获得更多信息
文件访问权限

跳过路径:坚持使用StorageFile。


所以你需要使用这样的fileopenpicker:



 //创建选择器对象并设置选项
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.FileTypeFilter.Add(" .jpg");
StorageFile file = await openPicker.PickSingleFileAsync();
if(file!= null)
{
var success = await Launcher.LaunchFileAsync(file);
}





< span style ="text-decoration:underline"> >>我怎样才能得到默认应用图标? (如
mp3文件中的凹槽音乐图标)


我对这个问题不太了解。您是说要获取存储文件的缩略图吗?



最好的问候,


Roy


hi

I'm trying to create a file explorer for windows 10 mobile...

I want get files and directories from sd card and add to a listbox

then by click on each item (files) open it with default app... (like opening pictures with photos app)

but I can't launch files

I found a code but it just open files from assets...

string CountriesFile = @"Assets\1.jpg"; StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; StorageFile file = await InstallationFolder.GetFileAsync(CountriesFile); var success = await Launcher.LaunchFileAsync(file);

how to open file from below address?
@"d:\a\b.jpg"

and another question...
how can I get default app icons? (like groove music's icon on mp3 files)

please help me

tnx a lot

解决方案

Hi Milad Poursaleh

>>how to open file from below address?

The app doesn’t have direct access to d:\. Instead of creating a file via path, you could use fileopenpicker to get the StorageFile. 

UWP apps have limited file access permissions, they can access certain file system locations like Application data locations and Application install directory by default. Apps can also access additional locations through the file picker, or by declaring capabilities.

You could get more information from File access permissions and Skip the path: stick to the StorageFile.

So you need to use a fileopenpicker like this:

// Create the picker object and set options
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.FileTypeFilter.Add(".jpg");
            StorageFile file = await openPicker.PickSingleFileAsync();
            if (file!=null)
            {
                var success = await Launcher.LaunchFileAsync(file);
            }


>>how can I get default app icons? (like groove music's icon on mp3 files)

I’m not quite understand about this question. Do you mean you want to get the thumbnail for the storage file?

Best Regards,

Roy


这篇关于文件管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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