|
-
May 19th, 2008, 09:06 AM
#1
Thread Starter
Member
[RESOLVED] Check if folder exists
Hi, Im making a program with a textbox were the user enteres a folder, but if the folder doesn't exist they get an error.
anyone know how to check if the folder exists?
Thanks!
-
May 19th, 2008, 09:10 AM
#2
Re: Check if folder exists
 Originally Posted by Durthor
Hi, Im making a program with a textbox were the user enteres a folder, but if the folder doesn't exist they get an error.
anyone know how to check if the folder exists?
Thanks! 
Does this help?
Code:
'Returns a boolean - True if the folder exists
Public Function DirExists(MyFile As String)
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
DirExists = fs.folderexists(MyFile)
End Function
Hope this helps...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 19th, 2008, 09:32 AM
#3
Thread Starter
Member
Re: Check if folder exists
 Originally Posted by koolsid
Does this help?
Code:
'Returns a boolean - True if the folder exists
Public Function DirExists(MyFile As String)
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
DirExists = fs.folderexists(MyFile)
End Function
Hope this helps...
how to use?
-
May 19th, 2008, 09:45 AM
#4
Re: Check if folder exists
Does this help?
Code:
'Paste this in a module
Public Function DirExists(Myfile As String)
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
DirExists = fs.folderexists(Myfile)
End Function
'Paste this either in a module or from whereevr you are calling it...
Sub aaa()
Dim Myfile As String
'Change this with the name of the folder
Myfile = "S:\New Folder"
'if the above folder exists then the msgbox
'below will return true
MsgBox DirExists(Myfile)
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 19th, 2008, 10:21 AM
#5
Thread Starter
Member
-
May 19th, 2008, 11:33 AM
#6
Re: [RESOLVED] Check if folder exists
Another way. Note, if the folder does already exist, it will do nothing
Code:
Private Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" _
(ByVal lpPath As String) As Long
Private Sub Command1_Click()
'the will create the directory "c:\this\is\a\test\directory\"
'if it doesn't already exist
MakeSureDirectoryPathExists "c:\this\is\a\test\directory\"
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|