Save data In a Custom Extension File And When It Opens A File, Open That Data In Different controls. (C#) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Save data In a Custom Extension File And When It Opens A File, Open That Data In Different controls. (C#)

What I need is that my application save data and a datetimepicker (with saveriledialog) and that if it is opened (with openfiledialog) it is written in different textbox

16th Apr 2018, 9:34 PM
SebGM2018
SebGM2018 - avatar
5 Answers
+ 1
//to open a file with filename from openFileDialog and place the contents of the file in a text box //https://www.dotnetperls.com/openfiledialog DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) // Test result. { textbox1.Text = File.ReadAllText(openFileDialog1.FileName); } //To save a file using filedialog, 1) get the filename if (saveFileDialog1.ShowDialog() == DialogResult.OK) { textBox1.Text = saveFileDialog1.FileName; } 2) Save contents in a file string createText = "Hello and Welcome" + Environment.NewLine; File.WriteAllText(saveFileDialog1.FileName, createText);
17th Apr 2018, 8:43 PM
sneeze
sneeze - avatar
+ 1
And I save that Variable Into A File?
18th Apr 2018, 2:48 AM
SebGM2018
SebGM2018 - avatar
0
Yeah but how can I do that some parts of the text put into different textbox?
17th Apr 2018, 9:40 PM
SebGM2018
SebGM2018 - avatar
0
Make a variable and concatenate the data of all the textboxes. string result= ""; result = textbox1.text + textbox2.text + textbox3.text;
17th Apr 2018, 9:46 PM
sneeze
sneeze - avatar
0
string result= ""; result = textbox1.text + textbox2.text + textbox3.text; File.WriteAllText(saveFileDialog1.FileName, result); http://www.java2s.com/Tutorials/CSharp/System.IO/File/C_File_WriteAllText_String_String_.htm
18th Apr 2018, 7:26 AM
sneeze
sneeze - avatar