Results 1 to 6 of 6

Thread: How to create temporary workspace and then deleted after used it

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    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?

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: How to create temporary workspace and then deleted after used it

    In which location the temporary folder is created?

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    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?

    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

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width