GetTempPath
C# Signature:
[DllImport("kernel32.dll")]
static extern uint GetTempPath(uint nBufferLength,
[Out] StringBuilder lpBuffer);VB Signature:
Declare Function GetTempPath Lib "kernel32.dll" (nBufferLength As Integer, _
<Out> lpBuffer As StringBuilder) As IntegerSample Code:
'TempFile.vb
'(DllImport declarations omitted)
Public Class TempFile
Public Function Create(ByVal astrFoldername As String, _
ByVal astrPrefix As String) As String
Dim tempPath As New StringBuilder(MAX_PATH - 14)
Dim tempName As New StringBuilder(MAX_PATH)
Dim lngRet As Integer
Dim result As String = ""
lngRet = 1
If (astrFoldername = "") Then
lngRet = GetTempPath(MAX_PATH - 14, tempPath)
astrFoldername = tempPath.ToString
End If
If (lngRet > 0 And lngRet <= MAX_PATH - 14) Then
lngRet = GetTempFileName(astrFoldername, astrPrefix, 0, tempName)
If lngRet <> 0 Then
result = tempName.ToString
End If
End If
Return result
End Function
End ClassSample Code:
Sample Code:
Última actualización