Output a watched Visual Studio variable to a file

前端 未结 4 1898
迷失自我
迷失自我 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条回答
  •  长情又很酷
    2020-12-09 18:30

    I found useful/demonstrative/shareable to save the variable as a json string to the file. From Immediate Window enter the following:

    string jsonedVariable = Newtonsoft.Json.JsonConvert.SerializeObject(VARIABLE);
    System.IO.File.WriteAllText(@"C:\FILENAME.json", jsonedVariable);
    

提交回复
热议问题