|
-
Oct 29th, 2009, 10:57 AM
#1
Thread Starter
Fanatic Member
Make command button create a new folder?
Hey everyone,
Does anybody know the code or how to make it so when a user presses a command button then it will make a new folder called "Recordings" in the app directory path?
Thanks
-
Oct 29th, 2009, 11:01 AM
#2
Re: Make command button create a new folder?
Place this in your Command button click code...
Code:
If Dir(App.Path & "Recordings") = "" Then
MkDir App.Path & "Recordings"
End If
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
-
Oct 29th, 2009, 11:27 AM
#3
Re: Make command button create a new folder?
 Originally Posted by koolsid
Place this in your Command button click code...
Code:
If Dir(App.Path & "Recordings") = "" Then
MkDir App.Path & "\Recordings"
End If
Fixed your post!
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Oct 29th, 2009, 12:14 PM
#4
Re: Make command button create a new folder?
Based on the name of that folder, I suspect you intend to write files there... which is a very bad idea.
For more information, see the article Where should I store the files that my program uses/creates? from our Classic VB FAQs
-
Oct 29th, 2009, 03:32 PM
#5
Thread Starter
Fanatic Member
Re: Make command button create a new folder?
thanks for the replys guys, One quick question!
How can i make it to create the recodings file in their my documents folder when they press the command button?
Thanks,
-
Oct 29th, 2009, 03:41 PM
#6
Re: Make command button create a new folder?
You could read this article.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Oct 29th, 2009, 04:28 PM
#7
Re: Make command button create a new folder?
 Originally Posted by abhijit
Fixed your post! 
Thanks Abhi... How did I miss that? 
@Jamie : What kind of recordings are these? Is it a personal application or a call recording software for common use? The reason I ask is that I am from the BPO industry and we have a common folder to store our recordings...
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
-
Oct 29th, 2009, 04:29 PM
#8
Thread Starter
Fanatic Member
Re: Make command button create a new folder?
Hi there, For some reasong when im clicking btnstart (command button) i get an error saying path not found? The whole idea is to make a folder in C:\ called recordings?
This is the code i used ? Have i broke something?
Thanks,
Code:
private Sub btnStart_Click()
If Dir("C:\Recordings") = "" Then
MkDir "C:\Recordings\"
End If
-
Oct 29th, 2009, 04:37 PM
#9
Re: Make command button create a new folder?
 Originally Posted by JamieWarren09
Hi there, For some reasong when im clicking btnstart (command button) i get an error saying path not found? The whole idea is to make a folder in C:\ called recordings?
This is the code i used ? Have i broke something?
Thanks,
Code:
private Sub btnStart_Click()
If Dir("C:\Recordings") = "" Then
MkDir "C:\Recordings\"
End If
This code should work for you.
Do you have write permission on the C: drive?
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Oct 29th, 2009, 04:39 PM
#10
Thread Starter
Fanatic Member
Re: Make command button create a new folder?
No worrys guys i've fixed it thanks anyways!!
-
Oct 29th, 2009, 04:40 PM
#11
Re: Make command button create a new folder?
 Originally Posted by JamieWarren09
No worrys guys i've fixed it  thanks anyways!!
1) Please post the fix that you had to do.
2) Don't forget to mark this thread as resolved.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Oct 29th, 2009, 04:42 PM
#12
Thread Starter
Fanatic Member
Re: Make command button create a new folder?
Actually i aint fixed it XD i'm gettting a path access error now, And its a audio recording software , like where you can record from your microphone e.t.c
Thanks.
-
Oct 29th, 2009, 04:44 PM
#13
Re: Make command button create a new folder?
What path are you specifying? Show us the exact code that you are using...
BTW Congrats on your 100 posts
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
-
Oct 29th, 2009, 04:49 PM
#14
Thread Starter
Fanatic Member
Re: Make command button create a new folder?
ok right ive now made it so it creates the folder "Recordings in the app directory"
but its still giving me an error of path/file access error. But it creates it the first time i click it, but if i click it again it will give me that error. Im using this code?
Code:
If Dir(App.Path & "Recordings") = "" Then
MkDir App.Path & "\Recordings"
End If
im guessing cause the folders already been created and cant be made again? as the fodlers already been made? so how can i make it so if its already been made it dont try & make the folder again?
Thanks,
-
Oct 29th, 2009, 04:52 PM
#15
Re: Make command button create a new folder?
Changed the code... now try it...
Code:
If Dir(App.Path & "\Recordings") = "" Then
MkDir App.Path & "\Recordings"
End If
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
-
Oct 29th, 2009, 05:25 PM
#16
Thread Starter
Fanatic Member
Re: Make command button create a new folder?
Awesome!
One more thing if you could help me with please?
in my app ive made it so the user puts in a text box the place the want the recording (file) to save to , for example if in the text box i put C:\jamie.wav
it saves the file in C:\ called jamie.wav
How ever is it possible to make it so it saves in the app dirctory\recordings?
the code ive tried is
File = ParseFile(App.Path & "\Recordings" \ "txtFile.Text")
butt it dont work, Basically i need it to save in the app path \ recordings \ txtfile.text
as the user will put in what they want the file to be called so if i typed in the text boz jamie itll save in
app directory \ recordings\ jamie.wav
thanks
-
Oct 29th, 2009, 05:29 PM
#17
Re: Make command button create a new folder?
Don't ask the user to enter the complete path... Let the user enter only a filename like "jamie.wav " and then when the user clicks on save, simply, append it to the path that you have. You can throw in an extra piece of code which will check if the filename is valid or not....
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
-
Oct 29th, 2009, 05:43 PM
#18
Thread Starter
Fanatic Member
Re: Make command button create a new folder?
That is what i am asking help for.
at the moment im using this code
File = ParseFile(App.Path & "\Recordings\txtFile.Text")
Txtfile.text is the text box,
But at the moment thats saving a file called txtfile.text into the recordings folder. But i need it to call the file what they put in txtfile.text..
Hope you understand what i mean.
thanks,
-
Oct 29th, 2009, 05:51 PM
#19
Re: Make command button create a new folder?
Code:
File = App.Path & "\Recordings\" & Text1.Text)
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
-
Oct 29th, 2009, 06:05 PM
#20
Thread Starter
Fanatic Member
Re: Make command button create a new folder?
aweosme that works, how ever,
with this code for creating the folder "recordings"
If Dir(App.Path & "\Recordings") = "" Then
MkDir App.Path & "\Recordings"
End If
it creates it fine, But then if i run the app and push the command button that codes in it gives me a error still cause the folders already been made!
But if i delete the folder it works fine
is htier away to ignore the code if the folders already been made?
Thanks,
-
Oct 29th, 2009, 06:21 PM
#21
Re: Make command button create a new folder?
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
-
Oct 29th, 2009, 06:32 PM
#22
Thread Starter
Fanatic Member
Re: Make command button create a new folder?
To be honest im not understanding anything in that thread?
Code:
Private Sub btnStart_Click()
If Dir(App.Path & "\Recordings") = "" Then
MkDir App.Path & "\Recordings"
End If
Is the code im using now, But i obviousily need soemthing in there to ignore creating the file if it already exists.... How will i go about that?
Sorry its just i dont understand what to change or what to add.
thanks
-
Oct 29th, 2009, 08:02 PM
#23
Re: Make command button create a new folder?
 Originally Posted by JamieWarren09
To be honest im not understanding anything in that thread?
Code:
Private Sub btnStart_Click()
If Dir(App.Path & "\Recordings") = "" Then
MkDir App.Path & "\Recordings"
End If
Is the code im using now, But i obviousily need soemthing in there to ignore creating the file if it already exists.... How will i go about that?
Sorry its just i dont understand what to change or what to add.
thanks
You said file, but I think you meant folder, correct?
Try this instead:
Code:
If Dir(App.Path & "\Recordings", vbDirectory or vbHidden or vbReadOnly or vbSystem) = "" Then
Last edited by LaVolpe; Oct 29th, 2009 at 08:05 PM.
Reason: forgot: Then
-
Oct 30th, 2009, 01:40 AM
#24
Re: Make command button create a new folder?
Another alternative is to use the MakeSureDirectoryPathExists API.
Sample usage:
Code:
Option Explicit
'this will create folders a, b and c at the same time
Private Sub Command1_Click()
MsgBox CreateFolder("C:\a\b\c")
End Sub
In a module:
Code:
Option Explicit
Public Declare Function MakeSureDirectoryPathExists Lib "IMAGEHLP.DLL" ( _
ByVal DirPath As String) As Long
'This will create subfolders if they don't exists, much better than MkDir
Public Function CreateFolder(ByVal NewPath As String) As Boolean
NewPath = AddSlash(NewPath)
'Call API
If MakeSureDirectoryPathExists(NewPath) <> 0 Then
'No errors, return True
CreateFolder = True
End If
End Function
Public Function AddSlash(ByVal strDirectory As String) As String
If InStrRev(strDirectory, "\") <> Len(strDirectory) Then
strDirectory = strDirectory + "\"
End If
AddSlash = strDirectory
End Function
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
|