Reputation: 263
I am faced with the issue of IIS express stopping abruptly without any stack trace while debugging in local.
I have found a work around for this by writing the stack trace to a html file.
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());
}
}
Now, I want to open this ExceptionHandlerError.html automatically everytime its modified when IIS Express stops.
I want bat file or a script to automate this. How can I go about this?
Note: I am connected to a network that doesn't allow administrator access and can't access event viewer.
Upvotes: 1
Views: 46
Reputation: 3471
You should be able to use this:
@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
Upvotes: 0
Reputation: 263
After some research, I was able to open the browser right after writing it to the file with
System.Diagnostics.Process.Start(file);
Final code is as below:
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);
Upvotes: 1