c#如何从“打开方式"获取文件路径? [英] c# How to get the file path from 'Open With'?

查看:535
本文介绍了c#如何从“打开方式"获取文件路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个文本编辑器,并且正在尝试编写代码以获取使用打开方式"在应用程序中打开文件时的文件路径.

I'm making a text editor and I'm trying to make a code to get the file path of a file when it's open in a application using 'Open With'.

详细信息:右键单击文件时,打开方式"是一个选项.该文件然后成为该应用程序的快捷方式.我尝试使用Process,但似乎无法从文件进程中获取路径.

Details: 'Open With' is an option when you right click on a file. The file then becomes a shortcut to the application. I have tried to use Process , but I couldn't seem to get the path from a file process.

问题:在c#中,使用打开方式"时如何获取文件的文件路径?

Question: In c#, how do you get the file path of a file when using 'Open With'?

编辑: 应用程序路径为C:\ Users \ Mayhem \ Documents

EDIT: Application path is C:\Users\Mayhem\Documents

文本文件路径为C:\ Users \ Mayhem \ Desktop

Text file path is C:\Users\Mayhem\Desktop

我需要获取文本文件"的文件路径.

I need to get the file path of 'text file'.

推荐答案

我的目标是使用打开方式"获取文件的路径. 这段代码显示了应用程序打开的所有路径,包括文件路径.

My goal is to get the path of a file using 'Open With'. This code shows all paths opened with the application, including the file path.

string[] openedPaths = Environment.GetCommandLineArgs();

这篇关于c#如何从“打开方式"获取文件路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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