From: Phil on
hello experts,
I am developing a software and I need to create a couple of temp files
when
the program is running.
I need a piece of advice regarding the best place to put them:
- Windows\temp directory
- User directory
- Program directory
- ??
Needless to say, the directory must exist and the user must have the
appropriate permissions.
What are the good practices regarding this question ?
Thanks
Phil
From: Doug Harrison [MVP] on
On Mon, 5 May 2008 08:43:18 -0700 (PDT), Phil <pbruyant(a)yahoo.com> wrote:

>hello experts,
>I am developing a software and I need to create a couple of temp files
>when
>the program is running.
>I need a piece of advice regarding the best place to put them:
>- Windows\temp directory
>- User directory
>- Program directory
>- ??
>Needless to say, the directory must exist and the user must have the
>appropriate permissions.
>What are the good practices regarding this question ?
>Thanks
>Phil

_mktemp
GetTempFileName
GetTempPath

--
Doug Harrison
Visual C++ MVP
From: Tom Serface on
I use this function:

CString GetTempFilePath(LPCTSTR strPattern)
{
CString csPath;
if(GetTempPath(_MAX_PATH,csPath.GetBuffer(_MAX_PATH+1)) != 0) {
csPath.ReleaseBuffer();
CString csTempFile;
if(GetTempFileName(csPath,strPattern,0,csTempFile.GetBuffer(_MAX_PATH+1))
!= 0) {
csTempFile.ReleaseBuffer();
return csTempFile;
}
}
return CString();
}

Tom

"Phil" <pbruyant(a)yahoo.com> wrote in message
news:c7604f77-3168-4193-b629-04209a1164e8(a)e39g2000hsf.googlegroups.com...
> hello experts,
> I am developing a software and I need to create a couple of temp files
> when
> the program is running.
> I need a piece of advice regarding the best place to put them:
> - Windows\temp directory
> - User directory
> - Program directory
> - ??
> Needless to say, the directory must exist and the user must have the
> appropriate permissions.
> What are the good practices regarding this question ?
> Thanks
> Phil

From: Joseph M. Newcomer on
Also, I've discovered in some cases that where people were writing "temporary files" it
was because "the data is too big to keep in memory, so I have to write a file", and in no
case that I found for this was the file > 1MB! So unless you need to pass these files on
to a subsequent processing program, consider carefully if you need to write one at all.
joe

On Mon, 5 May 2008 08:43:18 -0700 (PDT), Phil <pbruyant(a)yahoo.com> wrote:

>hello experts,
>I am developing a software and I need to create a couple of temp files
>when
>the program is running.
>I need a piece of advice regarding the best place to put them:
>- Windows\temp directory
>- User directory
>- Program directory
>- ??
>Needless to say, the directory must exist and the user must have the
>appropriate permissions.
>What are the good practices regarding this question ?
>Thanks
>Phil
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Tom Serface on
I mostly write temp files when I'm trying to insert of exclude something
from a file. The best way I've found to do it is to create a new file, copy
the stuff I want from the previous file, then delete the original file and
rename the temp file to the original file name. I do a lot of this in
memory if the file isn't too big, but it's lots easier to just do it in temp
files (imo).

Tom

"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:n5nu141dl5pqqj4focudo92n2hcb8hba0k(a)4ax.com...
> Also, I've discovered in some cases that where people were writing
> "temporary files" it
> was because "the data is too big to keep in memory, so I have to write a
> file", and in no
> case that I found for this was the file > 1MB! So unless you need to pass
> these files on
> to a subsequent processing program, consider carefully if you need to
> write one at all.
> joe
>