How to create temporary workspace and then deleted after used it
How I can create temporary folder in my machine and then deleted it after used it. Have a sample to start this?
Re: How to create temporary workspace and then deleted after used it
Here is how to create working folder in the user's temp directory.
If you need to delete that folder before exiting then search forum - there are some samples posted.
Code:
Option Explicit
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Sub Command1_Click()
Dim strTempFolder As String
Dim myWorkFolder As String
strTempFolder = String(128, Chr(0))
GetTempPath 100, strTempFolder
strTempFolder = Left$(strTempFolder, InStr(strTempFolder, Chr$(0)) - 1)
myWorkFolder = strTempFolder & "\myWorkFolder"
If Dir(myWorkFolder, vbDirectory) = "" Then
MkDir myWorkFolder
End If
End Sub
Re: How to create temporary workspace and then deleted after used it
In which location the temporary folder is created?
Re: How to create temporary workspace and then deleted after used it
Quoth the RB:
Quote:
Originally Posted by RinoBull
the user's temp directory.
-tg
Re: How to create temporary workspace and then deleted after used it
I would like to create temporary files in the location directory of my choice.
My location directory is in text1.text = C:\DATA
So, All temporary files will located in this directory folder. Howto do that?
Quote:
Option Explicit
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Sub Command1_Click()
Dim strTempFolder As String
Dim myWorkFolder As String
strTempFolder = String(128, Chr(0))
GetTempPath 100, strTempFolder
strTempFolder = Left$(strTempFolder, InStr(strTempFolder, Chr$(0)) - 1)
myWorkFolder = strTempFolder & "\myWorkFolder"
If Dir(myWorkFolder, vbDirectory) = "" Then
MkDir myWorkFolder
End If
End Sub
Re: How to create temporary workspace and then deleted after used it
Quote:
Originally Posted by matrik02
I would like to create temporary files in the location directory of my choice...
Under the sircumstances user may not have rights to anywhere but user's profile folders so using user's temp folder could be safer.
If it is a "temp" workspace then what's the problem?