How to open a folder with a file path vb 6
Hello every one i think all is fine
i want to open a folder with a file path
Example: i have a file path
c:\testfile.txt
now we want to open folder of this file where save my testfile.txt file using a command botton
i mean
{open containing folder}
please help me
give me any source code of visual basic 6.0
Thanks
Related Article: Wave file for VB 6.0 ...
is a Visual Basic 4 / 5 / 6 discussion thread by ThisIsNotYourS that has 5 replies and was last updated 3 months ago.
razamughal67
Junior Poster in Training
82 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
See if this help :
Function pathOfFile(fileName As String) As String
Dim posn As Integer
posn = InStrRev(fileName, "\")
If posn > 0 Then
pathOfFile = Left$(fileName, posn)
Else
pathOfFile = ""
End If
End Function
Call it using Shell() Function :
Private Sub Command1_Click()
Dim myPath As String
myPath = "D:\Dani\result.png"
Shell "explorer " & pathOfFile(myPath)
End Sub
Jx_Man
Senior Poster
3,521 posts since Nov 2007
Reputation Points: 1,468
Solved Threads: 514
Skill Endorsements: 64
Hi,
Simply use Combination of Drive ListBox, Directory List Box and File List Box from the tool box..
Regards
Veena
QVeen72
Veteran Poster
1,017 posts since Nov 2006
Reputation Points: 118
Solved Threads: 164
Skill Endorsements: 5
Hello everyone
and Jxman the code is work but we use avast antivirus when we start project and click command botton
then the avast antivirus say the explorer.exe the file prevalence/repuation is low show the suspicous alert !
and the some time close the program
please tell me what can i do ?
razamughal67
Junior Poster in Training
82 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Try to using API Fucntion instead of shell function :
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Function pathOfFile(fileName As String) As String
Dim posn As Integer
posn = InStrRev(fileName, "\")
If posn > 0 Then
pathOfFile = Left$(fileName, posn)
Else
pathOfFile = ""
End If
End Function
Private Sub Command1_Click()
Dim myPath As String
myPath = "D:\Dani\result.png"
ShellExecute 0, vbNullString, pathOfFile(myPath), vbNullString, vbNullString, 1
End Sub
Jx_Man
Senior Poster
3,521 posts since Nov 2007
Reputation Points: 1,468
Solved Threads: 514
Skill Endorsements: 64
Thanks jx you are a good man this code is good work
thanks
now we check mark solve this thread
Thanks thanks alot
razamughal67
Junior Poster in Training
82 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by
Jx_Man,
QVeen72
and
androidz