简体   繁体   中英

Load a file then save without save dialog

Stream scriptelfen;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if((scriptelfen = openFileDialog1.OpenFile())!= null)
                {
                string strfilename = openFileDialog1.FileName;
                string filetext = File.ReadAllText(strfilename);
                script_box.Text = filetext;

When I opened my file, it is displaying text or hex code extension. I want to be able to push save file. I don't have to do a save file dialog is this possible at all ?

MSDN中的WriteAllText

File.WriteAllText("C:\file.txt", "your content.");

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