View Full Version : سوال: کمک برای باز کردن فایل و ذخیره ان
  
oliya24
سه شنبه 08 شهریور 1390, 20:12 عصر
سلام دوستان من نمیدونم که چرا الان نمیتونم یه فایل با پسوند txt رو در برنامم باز کنم این هم کدی که مینویسم 
میشه کمک کنید
dim open file as new open file dialog()
open file dialog1.filter=text file(*.txt)|*.txt"
open file dialog1.show dialog()=..........
برای ذخیره کردن هم همین مشکل رو دارم
ariyaei
پنج شنبه 10 شهریور 1390, 19:26 عصر
Dim myStream As Stream = Nothing
        Dim openFileDialog1 As New OpenFileDialog()
  
        openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
        openFileDialog1.FilterIndex = 2
        openFileDialog1.RestoreDirectory = True
        openFileDialog1.Multiselect = True
        If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Try
                myStream = openFileDialog1.OpenFile()
                If (myStream IsNot Nothing) Then
                    'برای پاک کردن لیست
                    ListControl1.Items.Clear()
                    'برای خواندن فایلها و اضافه کردن به لیست
                    Dim Adress() = openFileDialog1.SafeFileNames
                    ListControl1.Items.AddRange(Adress)
                    'مسیر دایرکتوری فایلها در تکسباکس
                    Dim path As New System.IO.FileInfo(openFileDialog1.FileName)
                    TxtInput.Text = path.DirectoryName
                End If
            Catch Ex As Exception
            Finally
                ' Check this again, since we need to make sure we didn't throw an exception on open.
                If (myStream IsNot Nothing) Then
                    myStream.Close()
                End If
            End Try
        End If
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.