如何获得* .extension名称? [英] How to get *.extension name?

查看:73
本文介绍了如何获得* .extension名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我正在创建带有自定义文件扩展名的Windows窗体项目。

我想要的是当我双击带有新文件扩展名的图标时,获取文件名和文件路径。

示例:

Hello. I am creating Windows Form project with custom file extension.
What I want is when I double click an icon with the new file extension, to get the filename and filepath.
Example:

C:\TestDB\NewDatabase2\NewDatabase2.abc



我需要获取路径:


I need to get the path:

C:\TestDB\NewDatabase2



我还需要文件名:


I need also the filename:

NewDatabase2.abc





我尝试了什么:



我试过的东西喜欢:



What I have tried:

I have tried things like:

System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase




System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)



我只获取.exe名称。


I am only getting the .exe name.

推荐答案

这是解决方案:

c# - 关联扩展程序不会在双击时向应用程序发送文件名 - Stack Overflow [ ^ ]
This is the solution:
c# - Associated extension doesn't send file name to application on double click - Stack Overflow[^]


使用 FileInfo 类System.IO命名空间。
Use FileInfo Class Of system.IO Namespace.


这篇关于如何获得* .extension名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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