How to save textBox values into a xml-file(with naming an choosing directory)?


Joined
Aug 17, 2022
Messages
2
Reaction score
0
Considering I have a GUI with whatever-many textBoxes, how can i program it, to have a "Save"-button (picture 1), which gives you the the chance to save the xml-file wherever you want on your computer (picture 2), name it (picture 2) then and save the values, you wrote into the boxes?


File-Save.png
Save-As.png
 
Ad

Advertisements

Joined
Sep 4, 2022
Messages
13
Reaction score
0
Hello,

to achieve you need more components :
commonDialog / saveDialog ( for picture 2 )

and to write in one xml file of your choice :
look at xmlWriter / xmlReader

basically the LINQ to XML extension will help you to build your Xml pattern.
with XElement , this way :

myCONTENT = new Xelement("XMLname",value); with name as string, value the value you want,
result is : <XMLname>value</XMLname>

if you have childNodes in your full Xml pattern :
myCONTENT = new Xelement("name_one" , value_one , new Xelement ( "name_two , value2 ) )

<name_one> value_one
<name_two> value_two </name_two>
</name_one>

the instance of all Xelements will build you a Xml tree, with few levels in the Xml Tree.

by XDocument, you have to save your Xml tree :

XDocument.parse(myCONTENT);
XDocument.save( path_to_file );


as reminder , read about :
commonDialog and friend : FileDialog / FolderDialog
Linq To Xml
Xelement
Xdocument

It's sometimes to add as resources ( include / ) in VStudio to access their potential.
In your VStudio editor, select a keyword , then press F1, to reach the help online.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top