Atlanta Custom Software Development 

   Search        Code/Page

User Login



Forgot the Password?
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
» Regular Expr Tester
» Free Tools

GetTempFile - Create a temporary file

Total Hit ( 2385)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article



Click here to copy the following block
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
Private Declare Function GetTempPath Lib "Kernel32" Alias "GetTempPathA" (ByVal _
  nBufferLength As Long, ByVal lpBuffer As String) As Long

' Creates a temporary (0 byte) file in the \TEMP directory
' and returns its name

Public Function GetTempFile(Optional Prefix As String) As String
  Dim TempFile As String
  Dim TempPath As String
  Const MAX_PATH = 260
  ' get the path of the \TEMP directory
  TempPath = Space$(MAX_PATH)
  GetTempPath Len(TempPath), TempPath
  ' trim off characters in excess
  TempPath = Left$(TempPath, InStr(TempPath & vbNullChar, vbNullChar) - 1)
  ' get the name of a temporary file in that path, with a given prefix
  TempFile = Space$(MAX_PATH)
  GetTempFileName TempPath, Prefix, 0, TempFile
  GetTempFile = Left$(TempFile, InStr(TempFile & vbNullChar, vbNullChar) - 1)

End Function

Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with, SQL Server and other MS technologies. He is, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )

Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.