Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2004, 10:49 AM
Authorized User
 
Join Date: Mar 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default SaveFileDialog with c#

hello,
i have a form with many parameters. among others i have a menu item "File" that contain 'open...' and 'Save...'
when i choose the 'Save...' option i want to save all my operation so far(it`s mean that if i change any parameter or any control). and when i do open to this file i want to see all !! my changes.
///////////////////////////////
for exampl: in my form i have a TextBox, suppose i write anything in the text box and i save it, now i`m close all, init my program again and use 'open' option - now, i want to see my changes in the text box.
///////////////////////////////

my 'SaveFileDialog' function look like this:

this.saveFileDialog = new SaveFileDialog();
this.saveFileDialog.DefaultExt = "mddb";
this.saveFileDialog.Filter = "MDDB files (*.mddb)|*.mddb|All files (*.*)|*.*" ;
this.saveFileDialog.FilterIndex = 2 ;
this.saveFileDialog.RestoreDirectory = true ;

if(saveFileDialog.ShowDialog() == DialogResult.OK)
{
 if((myStream = saveFileDialog.OpenFile()) != null)
  {
  ????
 myStream.Close();
}
}

? - means mabye there my problem

thank you in advanced
koby

 
Old June 29th, 2004, 11:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

I think you have to pass this to a stream reader or stream writer, as such:

StreamWriter objWriter = New StreamWriter(saveFileDialog.OpenFile())
objWriter.WriteLine(txtFile.Text)

The dialog doesn't automatically save the text, I believe.

Brian

Then perform some write options
 
Old July 6th, 2004, 02:19 AM
Authorized User
 
Join Date: Jul 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
Default

While you CAN use the save file dialog for saving text files, I would recommend using it merely for getting the name of the file to be saved and then using a TextWriter or another stream tool to do the work. Seperation of Concerns.

www.CoderForRent.com
Get A Computer Job!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using SaveFileDialog to save SQL DB file jscammell VB Databases Basics 4 April 14th, 2007 10:02 AM
About SaveFileDialog,help!! revo1021 C# 2005 2 June 24th, 2006 01:37 AM
saveFileDialog disables SIP on "OK" Rissa VB.NET 2002/2003 Basics 0 March 17th, 2004 01:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.