c#如何从“打开方式"获取文件路径?

编程入门 行业动态 更新时间:2024-10-10 23:27:21
本文介绍了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#如何从“打开方式"获取文件路径?

本文发布于:2023-11-13 06:23:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583688.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   方式   文件   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!