visual-studio Visual Studio 打开文件问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16074/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:22:42  来源:igfitidea点击:

Visual Studio open files question

visual-studiovisual-studio-2008settingsprojects-and-solutions

提问by Mikey P

Is it possible to open a project in Visual Studio 2008 without opening all the files that were previously opened last time I had the project open. I have a habit of keeping many files open as I am working on them, so next time I open the project, it (very slowly) loads up a bunch of files into the editor that I may not even need open. I have searched through the settings and cannot find anything to stop this behavior.

是否可以在 Visual Studio 2008 中打开一个项目而不打开我上次打开该项目时以前打开的所有文件。我有一个习惯,在我处理它们时保持许多文件处于打开状态,所以下次我打开项目时,它(非常缓慢地)将一堆文件加载到编辑器中,我什至可能不需要打开这些文件。我已经搜索了设置,但找不到任何可以阻止这种行为的方法。

回答by Biri

Simply delete the .suo file. It contains the list of open files.

只需删除 .suo 文件。它包含打开文件的列表。

回答by Ryan Lundy

A bit of research turns up the fact that you can do it with a macro:

一些研究表明您可以使用宏来做到这一点:

  • Create a new macro (or use an existing one). You should see a module called EnvironmentEventsin Macro Explorer. (For details, see here.)
  • Open the EnvironmentEventsmodule.
  • Put in this code:

    Public Sub CloseDocsOnExit() Handles SolutionEvents.BeforeClosing
        DTE.ExecuteCommand("Window.CloseAllDocuments")
    End Sub
    
  • Save and Build the macro.
  • Open a whole bunch of documents in your solution, then close Visual Studio.
  • Yay! No more open documents!
  • (Note: Despite that it says SolutionEvents, it also works if you're working on a project that doesn't have a solution.)
  • 创建一个新宏(或使用现有宏)。您应该会看到EnvironmentEvents在宏资源管理器中调用的模块。(有关详细信息,请参见此处。)
  • 打开EnvironmentEvents模块。
  • 放入这段代码:

    Public Sub CloseDocsOnExit() Handles SolutionEvents.BeforeClosing
        DTE.ExecuteCommand("Window.CloseAllDocuments")
    End Sub
    
  • 保存并构建宏。
  • 在解决方案中打开一大堆文档,然后关闭 Visual Studio。
  • 好极了!没有更多的打开文件!
  • (注意:尽管它说的是 SolutionEvents,但如果您正在处理一个没有解决方案的项目,它也可以工作。)

回答by travis

I never realized how much that annoyed me as well! I haven't been able to find a setting, but in Options > Environment > Keyboardyou can bind a shortcut to Window.CloseAllDocuments. ALT+Xwas unbound for me so I just used that. I'm interested if there's some hidden setting to automatically do this on solution exit though (or load).

我从来没有意识到这也让我很恼火!我一直没能找到设置,但在Options > Environment > Keyboard你可以绑定一个快捷方式到Window.CloseAllDocuments. ALT+X对我来说是不受约束的,所以我只是使用了它。我很感兴趣,如果有一些隐藏的设置可以在解决方案退出(或加载)时自动执行此操作。

回答by travis

Try the following:

请尝试以下操作:

  1. Close the program after closing all files.
  2. Make a copy of [whatever].suo
  3. Open the solution again, open some files, and exit.
  4. Copy (don't move) the old .suo file over the one that was just generated.
  5. Make the .suo file read only.
  1. 关闭所有文件后关闭程序。
  2. 复制 [whatever].suo
  3. 再次打开解决方案,打开一些文件,然后退出。
  4. 将旧的 .suo 文件复制(不要移动)到刚刚生成的文件上。
  5. 将 .suo 文件设为只读。

If you have a repository you might want to check that file in.

如果您有一个存储库,您可能想要签入该文件。

I suggest this because I was having the reverse problem, where it wasn't opening my old files automatically, and the cause was a .suo file that had been checked into the repository and was (for some reason) not being overwritten by Studio. The file wasn't even write protected.

我建议这样做是因为我遇到了相反的问题,它没有自动打开我的旧文件,原因是一个 .suo 文件已经签入存储库并且(由于某种原因)没有被 Studio 覆盖。该文件甚至没有写保护。

回答by Greg Hurlman

Edit: Totally read the question wrong at first - ignore my first (now gone) answer. :)

编辑:一开始完全读错了问题 - 忽略我的第一个(现在已经消失)的答案。:)

I changed the keyboard mapping for CTRL-SHIFT-C from bringing up the Class View to closing all document windows - something I use several orders of magnitude more often - and then I just clear my workspace before closing a solution.

我将 CTRL-SHIFT-C 的键盘映射从打开类视图更改为关闭所有文档窗口 - 我经常使用几个数量级 - 然后在关闭解决方案之前清除我的工作区。

回答by Mikey P

I was hoping for something a little more automatic. VS will create a new .suo file every time the project is saved. So I would have to delete that file every time I open the project. I also don't want to have to remember to close all the files before closing VS.

我希望有一些更自动化的东西。每次保存项目时,VS 都会创建一个新的 .suo 文件。所以我每次打开项目时都必须删除该文件。我也不想在关闭 VS 之前记住关闭所有文件。

Other IDEs that I have used have similar functionality, but also make it rather simple to turn on/off.

我使用过的其他 IDE 具有类似的功能,但也使打开/关闭变得相当简单。

Thanks for your help.

谢谢你的帮助。

回答by Biri

Or you can close all open document from the Window menu before closing VS.

或者您可以在关闭 VS 之前从“窗口”菜单中关闭所有打开的文档。

回答by sam

In Visual Studio 6.0 (VC++), the procedure is slightly different.

在 Visual Studio 6.0 (VC++) 中,过程略有不同。

Delete the .ncb file (located normally in the same place as your .dsp or .dsw files).

删除 .ncb 文件(通常与 .dsp 或 .dsw 文件位于同一位置)。

回答by gal

The only way works for me is : change the project location and again reopen the solutions form there. :)

对我有用的唯一方法是:更改项目位置并再次在那里重新打开解决方案表单。:)