Windows 如何在修改html文件时打开它?

Windows 如何在修改html文件时打开它?,windows,shell,powershell,batch-file,cmd,Windows,Shell,Powershell,Batch File,Cmd,我面临着IIS express在本地调试时突然停止而没有任何堆栈跟踪的问题 我通过将堆栈跟踪写入html文件找到了解决方法 string file = @"C:\Users\INLASKD\Desktop\ExceptionHandlerError.html"; using (FileStream fs = new FileStream(file, FileMode.Create)) { using (StreamWriter w = new StreamWriter(fs, Encod

我面临着IIS express在本地调试时突然停止而没有任何堆栈跟踪的问题

我通过将堆栈跟踪写入html文件找到了解决方法

string file = @"C:\Users\INLASKD\Desktop\ExceptionHandlerError.html";
using (FileStream fs = new FileStream(file, FileMode.Create))
{
   using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
     {
        w.WriteLine(sb.ToString());
     }
}
现在,我想在每次IIS Express停止时修改此ExceptionHandlerError.html时自动打开此ExceptionHandlerError.html

我想要一个bat文件或一个脚本来自动化这个。我该怎么办


注意:我连接的网络不允许管理员访问,也无法访问事件查看器

您应该能够使用以下功能:

@echo off
set "file=C:\Users\INLASKD\Desktop\ExceptionHandlerError.html"
:loop
attrib "%file%" | findstr /B /L A 1>nul
if %errorlevel% equ 0 (
::open the file here
start "" "%file%"
attrib -A "%file%"
)
timeout /t 2 /nobreak >nul
goto loop

经过一些研究,我能够在将浏览器写入文件后立即打开浏览器

System.Diagnostics.Process.Start(file);
最终代码如下:

    string file = @"C:\Users\iraacn-9ajm\Desktop\ExceptionHandlerError.html";
    using (FileStream fs = new FileStream(file, FileMode.Create))
    {
    using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
           {
           w.WriteLine(sb.ToString());
           }
    }

    System.Diagnostics.Process.Start(file);

谢谢但是这个bat文件会一直运行吗?没有将它放在调度程序中?是的,尽管我忘记编辑存档属性,所以我只是修复了它。
cmd
控制台实际上不是事件驱动的。我认为最好让异常处理程序在编写堆栈跟踪之后启动html文件。通过批处理脚本监视文件的大小更改并不是我认为最优雅的解决方案。Hmmm。我该怎么做?不确定。我不知道IIS Express允许您在提出问题之前编写自己的异常处理程序。事实上,在你提出问题之前,我不知道IIS Express是不是很糟糕<代码>:)那是C代码,不是吗?我想在
下面使用
代码块可以创建一个
新流程()
对象,填充它的
StartInfo
属性,然后调用它的
Start()
方法。但这完全是胡乱猜测。我没有用C写太多东西。谢谢你的建议。我已经在下面发布了解决方案。