C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » File Operations »

How to use SaveFileDialog to save text files?


Posted Date: 18 Jun 2007    Resource Type: Code Snippets    Category: File Operations
Author: Abhishek AryaMember Level: Diamond    
Rating: 1 out of 5Points: 10



This code sample shows how to save a textfile using SaveFileDialog


Stream myStream ;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();

saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
saveFileDialog1.FilterIndex = 2 ;
saveFileDialog1.RestoreDirectory = true ;

if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if((myStream = saveFileDialog1.OpenFile()) != null)
{
StreamWriter wText =new StreamWriter(myStream);

wText.Write(" your text");

myStream.Close();
}
}



Responses

Author: pieter    18 Aug 2009Member Level: Bronze   Points : 1
Just remember to Flush and close your WText object.... otherwise nothing gets written :)


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to the disk size and the free disk space?
Previous Resource: C# How to sort files by their creation date?
Return to Discussion Resource Index
Post New Resource
Category: File Operations


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use