Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/03/2012, 06:33
balboa
 
Fecha de Ingreso: agosto-2011
Mensajes: 59
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: Guardar URL de archivos y recuperarla para abrirles

Hola amigos.

Ya conseguí solucionar mi problema.Dejo el código y la explicación de cómo lo resolví:

Código:
 Dim myStream As Stream = Nothing
        Dim openFileDialog1 As New OpenFileDialog()
        'Dim saveFileDialog1 As New SaveFileDialog()

        openFileDialog1.InitialDirectory = "Desktop\"
        openFileDialog1.Filter = "All files (*.*)|*.*"
        openFileDialog1.FilterIndex = 2
        openFileDialog1.RestoreDirectory = True



        If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Try
                myStream = openFileDialog1.OpenFile()
                If (myStream IsNot Nothing) Then

                    'Esta instruccion es para abrir el archivo
                    'Process.Start(openFileDialog1.FileName)
                    'Dim pathfile As String = My.Computer.FileSystem.GetName(openFileDialog1.FileName)
                    Dim pathfile As String = My.Computer.FileSystem.GetParentPath(openFileDialog1.FileName)
                    Dim pathfile2 As String = My.Computer.FileSystem.GetName(openFileDialog1.FileName)
                    Me.txtsubida.Text = pathfile + "\" + pathfile2

                End If
            Catch Ex As Exception
                MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
            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
Mediante la directiva "openFileDialog1", abro mi explorador de windows para seleccionar el fichero que desee.
Después con otras dos directivas guardo el nombre del fichero (GetName) y la ruta (GetParentPath) y junto las dos para tener la ruta completa.

Espero que les sirva y doy el problema zanjado.

Un saludo