MyTetra Share
Делитесь знаниями!
Создание произвольного файла во временной папке Windows
Время создания: 16.03.2019 23:43
Раздел: !Закладки - VBA - Access - msa.polarcom.ru - 12 Папки и Файлы
Запись: xintrea/mytetra_db_adgaver_new/master/base/15320180805y0x8e8vmo/text.html на raw.githubusercontent.com

Создание произвольного файла во временной папке Windows

По материалам: https://support.microsoft.com/

Sample Function to Generate a Random Temporary File Name
Create a module and type the following procedure:
Note that the name of the temporary file is displayed in the Debug window. The file contains the line "This is a Temp file." After you have verified that the file exists in your Temp folder, you can delete it.

Function MakeTempFileName(Extension As String) As String

On Error Resume Next

Dim Isfile As Integer, FHandle As Integer, Cntr As Integer

Dim WinTemp As String, TF As String

Isfile = False

FHandle = FreeFile

Do

WinTemp = Environ("TEMP") & "\"

For Cntr = 1 To 8

WinTemp = WinTemp & Mid(LTrim(Str(CInt(Rnd * 10))), 1, 1)

Next

TF = Trim(WinTemp$) & "." & Extension


Open TF For Output As #FHandle

Debug.Print TF

Print #FHandle, "This is a Temp file"

Loop While Err > 0

Close #FHandle

MakeTempFileName = TF


End Function




Type the following line in the Debug window (or Immediate window in versions 1.x and 2.0), and then presss ENTER:
TempFileName$ = MakeTempFileName("TMP")

Так же в этом разделе:
 
MyTetra Share v.0.59
Яндекс индекс цитирования