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
Printable View
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
Place this in your Command button click code...
Code:If Dir(App.Path & "Recordings") = "" Then
MkDir App.Path & "Recordings"
End If
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
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,
You could read this article.
Thanks Abhi... How did I miss that? :eek2:Quote:
Originally Posted by abhijit
@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...
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
No worrys guys i've fixed it :D thanks anyways!!
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.
What path are you specifying? Show us the exact code that you are using...
BTW Congrats on your 100 posts ;)
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?
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?Code:If Dir(App.Path & "Recordings") = "" Then
MkDir App.Path & "\Recordings"
End If
Thanks,
Changed the code... now try it...
Code:If Dir(App.Path & "\Recordings") = "" Then
MkDir App.Path & "\Recordings"
End If
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
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....
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,
Code:File = App.Path & "\Recordings\" & Text1.Text)
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,
To be honest im not understanding anything in that thread?
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?Code:Private Sub btnStart_Click()
If Dir(App.Path & "\Recordings") = "" Then
MkDir App.Path & "\Recordings"
End If
Sorry its just i dont understand what to change or what to add.
thanks
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