简体   繁体   English

Visual Studio-启动时读取指定的文件

[英]Visual Studio - Read specified file on launch

I'm working with a simple program that has to read data from a txt file and than display it. 我正在使用一个简单的程序,该程序必须从txt文件读取数据并显示它。 The thing is that i would like to read a specified extension files (for example .log) automatically. 问题是我想自动读取指定的扩展名文件(例如.log)。

So, i would like to do it as a simple Windows user - double click file and than the program opens. 因此,我想以简单的Windows用户的身份进行操作-双击文件,然后打开程序。 The problem is that this program is working but it's nor loading the file on start and tbh i have no idea if I should program it somehow? 问题是该程序正在运行,但是它也没有在启动和加载时加载文件,我不知道是否应该以某种方式对其进行编程? Any hints? 有什么提示吗?

Thanks! 谢谢!

Sound like you want to associate file type with your application. 听起来好像您想将文件类型与应用程序关联。 This is done via windows registers. 这是通过Windows寄存器完成的。 Try for example this article http://msdn.microsoft.com/en-us/library/windows/desktop/hh127451(v=vs.85).aspx 例如,尝试使用本文http://msdn.microsoft.com/zh-cn/library/windows/desktop/hh127451(v=vs.85).aspx

The easiest way to make it load the file automatically is to allow it accept the file path as a parameter and then do a load operation. 使它自动加载文件的最简单方法是允许它接受文件路径作为参数,然后执行加载操作。 As for having your program open automatically when a user double clicks on that file type I would recommend checking out this CodeProject 至于当用户双击该文件类型时自动打开程序,我建议您检查一下此CodeProject

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Visual Studio中使用StringReader从文本文件读取 - Read from text file with StringReader in Visual Studio 在Visual Studio 2012中读取edmx文件的必备条件 - Requisites to read an edmx file in Visual Studio 2012 系统找不到 Visual Studio 2022 中指定的文件 - The system cannot find the file specified in Visual Studio 2022 以编程方式启动 Visual Studio Code - Launch Visual Studio Code Programmatically 启动时的 Visual Studio 调试器异常 - Visual Studio Debugger exception on launch 如何在Visual Studio中对命令应用程序进行编程以读取批处理文件 - How to program a command application in visual studio to read a batch file 在Visual Studio 2010 C#项目中读取链接的xml文件 - Read a linked xml file in Visual Studio 2010 C# project 如何从 Visual Studio 解决方案/项目中读取文件? - How to read file from Visual Studio solution/project? 生成Antlr时,Visual Studio在未命名文件的情况下给出了错误“找不到指定的文件” - When building Antlr, Visual Studio gives an error “cannot find the file specified” without naming the file “无法启动 Visual Studio”错误(在 Mac 上) - “Could not launch Visual studio” error (on Mac)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM