locked
How to open a txt with a DocumentList RRS feed

  • Question

  • Hi

    I am programming Windows Mobile 6.1, compact framework 3.5 in Visual Basic

    I have some trouble with the DocumentList control. the main problem is that I can't figure out how to get the file path with dirictory and filename.
    the command I am looking for is a command simmular to the command in the Openfiledialog control called "Filename".

    Here is my code

        Private Sub DocumentList1_DocumentActivated(ByVal sender As System.Object, ByVal e As Microsoft.WindowsCE.Forms.DocumentListEventArgs) Handles DocumentList1.DocumentActivated
            Dim fp As IO.StreamReader
            If DocumentList1.FilterIndex = 0 Then
                Try
                    fp = IO.File.OpenText(DocumentList1)
                    FormOpenNote.TextBoxNoteTxt.Text = fp.ReadToEnd
                    fp.Close()
                Catch ex As Exception
                End Try
                FormOpenNote.Show()
    
            ElseIf DocumentList1.FilterIndex = 1 Then
                Try
                    fp = IO.File.OpenText(DocumentList1)
                    FormOpenNote.TextBoxNoteTxt.Text = fp.ReadToEnd
                    fp.Close()
                Catch ex As Exception
                End Try
                FormPaint.Show()
            End If
        End Sub
    


    thanks
    Monday, April 6, 2009 10:39 PM

Answers

  • Hi,

    You can track the selected file by handling the DocumentActivated event, as shown in the code below:

    Private selectedFile As String = String.Empty
    Private Sub documentList1_DocumentActivated(ByVal sender As Object, ByVal e As Microsoft.WindowsCE.Forms.DocumentListEventArgs)
        selectedFile = e.Path
        MessageBox.Show(selectedFile)
    End Sub

    Regards,
    Chunsheng Tang


    Please mark the post that helps you, and unmark that does not. This benefits our community members.
    • Marked as answer by warrentang Monday, April 13, 2009 2:43 AM
    Friday, April 10, 2009 10:15 AM