简体   繁体   中英

C# wpf saving “files”, settings, state

I'm trying to learn about saving state and settings in my applications.

As a simple example, say I have an application where I drag images onto a canvas from explorer. What is the best way to save this info if I want to get it back?

I would have to save -> the images path, and where it is on the Canvas.

So the very simple solution would be to create and save a text file with values for path of image, and Canvas.GetTop and Canvas.GetLeft.

"C:\\users\\<username\\pic1.png", 100, 150
"C:\\users\\<username\\pic2.png", 300, 400

then load them when I want.

What is the better solution, and how is this done in general?

Get .Left and stuff during the OnClosing(...) event. Just save that to an XML file and in public MainWindow(), just read the XML file and load the settings

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM