且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#中的Clr20r3错误

更新时间:2021-11-16 22:29:48

找不到目录非常清楚。

1)记录您的异常并查看代码中的位置。

2)要么在启动时创建目录(即Program.cs)或在使用它之前检查它是否与 Directory.Exists()一起存在。
Directory not found is pretty clear.
1) log your exception and see where in your code it is.
2) either create the directory on start up (i.e. Program.cs) or check if it exists with Directory.Exists() before using it.


Application.Run是执行整个程序的代码 - 它不仅仅是执行一行代码,而是一个巨大的数字!



你需要开始记录MainForm中发生的事情 - 从构造函数和明显的Event handl开始加载和显示。我们的想法是缩小yoru代码中导致异常的位置,因此在最基本的用途 File.AppendText [ ^ ]将我得到这么远的消息添加到文件中,以便在崩溃和工作后进行查看在哪里没有得到!当你知道粗糙区域时,你可以开始专注于使用更详细的日志记录语句,直到你得到一个合理的代码块。



然后你就可以开始找出哪个文件夹缺失,以及为什么。

但我们可以为你做任何事情!
Application.Run is the code which executes your whole program - it's not just a single line of code that that performs, it's a huge number!

You need to start logging what is going on in your MainForm - start with the constructor and the obvious Event handlers Load and Shown. The idea is to "narrow down" where in yoru code the exception is being caused, so at its most basic use File.AppendText[^] to add "I got this far" messages to a file so you can review after teh crash and work out where it didn't get! When you know the rough area, you can start to focus in using more detailed logging statements until you get it down to a reasonable chunk of code.

Then you can start working out which folder is missing, and why.
But we can;t do any of that for you!