weidagang2046的专栏

物格而后知致
随笔 - 8, 文章 - 409, 评论 - 101, 引用 - 0
数据加载中……

C# save text file using SaveFileDialog

// How to use SaveFileDialog to save text files?

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(); 
                  } 
            } 

from: http://zamov.online.fr/EXHTML/CSharp/CSharp_302155.html

posted on 2006-04-12 15:29 weidagang2046 阅读(1512) 评论(0)  编辑  收藏 所属分类: Windows


只有注册用户登录后才能发表评论。


网站导航: