Output a watched Visual Studio variable to a file

前端 未结 4 1897
迷失自我
迷失自我 2020-12-09 17:50

Is there a way in Visual Studio (2008 if it matters) that I can, in debug/break mode, write the contents of a variable to a text/XML file?

The scenario is that I ha

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 18:11

    Thanks to Richard's answer, this is working for me.

    System.IO.File.WriteAllBytes(@"c:\Temp\temp.txt", myVar);

    Make sure that C:\Temp exists.

    The reason for writing to a folder and not to the root C:\ is to avoid UnauthorizedAccessException when not running Visual Studio as administrator.

提交回复
热议问题