原来用C#写文件的时候都不喜欢用路径,例如,我会用
FileStream fsEncrypted = new FileStream("data.xml", FileMode.Create, FileAccess.Write);
Gets and sets the fully qualified path of the current directory; that is, the directory from which this process starts.
我以为这样就可以了,结果试了还是不行,原来 Environment.CurrentDirectory 也受 OpenFileDialog 的影响,
实在没办法了,又查,这次用了 Application.StartupPath
好了,这下存的文件不会乱跑了。