Results 1 to 3 of 3

Thread: Create folder in temp directory

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    11

    Create folder in temp directory

    Considered the following code:
    Code:
    Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
                    (ByVal nBufferLength As Long, _
                    ByVal lpBuffer As String) As Long
    Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long
    
    Public Function GetTempDir() As String
        Dim sBuffer As String
        Dim lRetVal As Long
    
        sBuffer = String(255, vbNullChar)
    
        lRetVal = GetTempPath(Len(sBuffer), sBuffer)
    
        If lRetVal Then
            GetTempDir = Left$(sBuffer, lRetVal)
        End If
    End Function
    
    Private Sub Command1_Click()
    Dim sBuffer As String
     sBuffer = String$(255, vbNullChar)
    GetTempFileName GetTempDir(), "aaa", 0, sBuffer
    MsgBox sBuffer
    
    End Sub
    My question is:
    1)Does the code above guarantee to generate a unique filename?
    2)This code can only generate file with .tmp extension in user temp directory, how to create a folder with unique name?
    Last edited by Hack; Jul 10th, 2007 at 09:37 AM. Reason: Added [code] [/code] tags

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