PEGAR NOME DO ARQUIVO

USUARIO.EXCLUIDOS 25/05/2005 19:21:15
#85238
Olá,

Como faço para pegar o nome do arquivo que o usuário seleciona no commondialog? Eu tentei usar a propriedade filename, mas ela retorna o diretorio completo (ex:C:\Pasta
omearquivo). Eu queira pegar somente o nome do arquivo. Como faço? Obrigado.

Luiz
GABRIEL.LOGAN 25/05/2005 20:15:13
#85247
Resposta escolhida
Veja:

http://www.vbmania.com.br/vbmdetail.php?varID=2944

Esse código parte dele eu devo ao amigo MIGUEL_ANGELO, ele me tirou uma dúvida de como retirar a árvore de um diretóio e deixar somente o nome do arquivo:

'-----RETIRAR A àRVORE DE UM DIRETÓ“RIO POR MIGUEL_ANGELO:

'usaremos um Text Box e um Botão:

Private Sub Command1_Click()

Dim Arquivo() As String
Dim DiretorioArq As String

DiretorioArq = Text1.Text
Arquivo = Split(DiretorioArq, "\")
Text1.Text = Arquivo(UBound(Arquivo))

End Sub


'-----RETIRAR O NOME DO ARQUIVO DE UM STRING DO TIPO ( DIRETÓ“RIO + ARQUIVO) POR GABRIEL_LOGAN


'usaremos 2 Text Box e um Botão:

Private Sub Command1_Click()
Dim Arquivo() As String
Dim DiretorioArq As String
Dim vla As Integer

DiretorioArq = Text1.Text
Arquivo = Split(DiretorioArq, "\")
Text2.Text = Arquivo(UBound(Arquivo))

Text1.SelStart = 0
Text2.SelStart = 0

Text1.SelLength = Len(Text1.Text)
Text2.SelLength = Len(Text2.Text)

vla = Text1.SelLength - Text2.SelLength
Text1.Text = Left$(Text1.Text, InStr(Text1.Text, "\") + (vla - 3))
End Sub

Private Sub Form_Load()
Text2.Visible = False
End Sub



'Pra finalizar Vejam:

RETIRANDO A EXTENSÃO DO ARQUIVO:

'==========

Arquivo$ = Left$(Arquivo$, InStr(Arquivo$, ".") - 1)

'==========
USUARIO.EXCLUIDOS 25/05/2005 21:16:21
#85254
Valeu Gabriel.

Luiz
GABRIEL.LOGAN 25/05/2005 21:17:16
#85256
Estamos ai pra isso.
Tópico encerrado , respostas não são mais permitidas