Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How does VFP create the temporal filenames?
Message
 
 
To
01/08/2001 00:36:04
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00538049
Message ID:
00538170
Views:
9
See API#73 and API#12707 by Nancy.

>Martin-
>
>>I would like to know How does VFP create the eight characters temporal file names?
>
>Do you mean how can you create good 8-character file names? (see Mauricio's suggestion.) Or do you mean how does VFP do it? I don't know how it happens under the cover, but I suspect it uses the Windows API somehow. Dunno. But you can, too, if you want. It's easy, fast, and the file names are _guaranteed_ to be unique.
>
>The following a method stripped out of a class I have to do things with the windows temporary directory so some of it isn't relevent to you (.LastSubDir is an application-specific subdirectory I make off the Window's temporary directory, for example).
>
>
PROCEDURE GetUniqueFile( tcPrefix )
>	*!* This method creates a file with a .TMP extension in the system temporary directory
>	*!* Returns the fully qualified path including file name.
>	*!*
>	*!* Pass a 3-character prefix to use for the temporary file names
>	*!*
>	DECLARE LONG GetTempFileName IN "kernel32" ;
>		STRING lpszPath,;
>		STRING lpPrefixString,;
>		LONG wUnique,;
>		STRING lpTempFileName
>
>	WITH THIS
>		LOCAL lnReturn, lcTmpPath, lcTmpName, lcPrefix
>		lcPrefix  = IIF( EMPTY( tcPrefix ), "UNK", tcPrefix )
>		lcTmpName = REPLICATE( ' ', 576 )
>		lcTmpPath = .GetPath()
>		*!* Pass the directory to create the temporary filename in, the prefix to use, 0, and a variable to contain the created file name.
>		lnReturn  = GetTempFileName( lcTmpPath + .LastSubdir, lcPrefix, 0, @lcTmpName )
>		.LastFile = lcTmpName
>		.LastPrefix = lcPrefix
>	ENDWITH
>	RETURN TRIM( STRTRAN( lcTmpName, CHR(0), '' ) )
>ENDPROC
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform