【问题标题】:Dynamically created files are not in the solution explorer动态创建的文件不在解决方案资源管理器中
【发布时间】:2020-04-18 16:04:54
【问题描述】:

这段代码创建了一个新的 html 文档,我可以在文件资源管理器中看到它,我可以打开它,但不在解决方案资源管理器中(我使用的是 Visual Studio 2019,这是一个 ASP.NET网络表单项目,如果有帮助的话):

string fielName = Server.MapPath("~/Created files/" + Name + ".html"); // Works ??

            TextWriter tw = new StreamWriter(fielName);

            tw.WriteLine(@"

            <!DOCTYPE html>

            <html>
            <head>
                <link rel=""stylesheet"" href=""https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"">
                <script src=""https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js""></script>
                <!--Latest compiled JavaScript-->
                <script src=""https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js""></script>

                <title></title>
            </head>
            <body>
            </body></html>");

             // close the stream
             tw.Close();

我已经尝试关闭 VS 并再次打开它,但文件仍然不在解决方案资源管理器中,如果我可以做一些代码方面的事情或其他事情,非常欢迎,提前致谢。

【问题讨论】:

  • 解决方案资源管理器探索解决方案,而不是文件系统。如果您希望文件包含在解决方案中,则需要将其添加到项目中。如果您真的愿意,可以以编程方式更新 .csproj 文件,但您仍需要在 Visual Studio 中重新加载项目才能显示。

标签: c# html asp.net webforms visual-studio-2019


【解决方案1】:

您是否在解决方案资源管理器中激活了“显示所有文件”选项?解决方案资源管理器顶部有一个图标按钮。

【讨论】:

    猜你喜欢
    • 2018-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-04
    • 2017-10-20
    • 2019-03-24
    • 1970-01-01
    • 2013-11-20
    相关资源
    最近更新 更多