PDA

View Full Version : Creating a Tmporary file with random number ..



npc
31st May 2006, 06:08
Hi,

Actually I want to create a temporary file like temp.txt.<random number>,
because temp.txt file is already exists in that directory.

then I want to assign that temporary file to QFile,

how can I do that ?

Thanks for your replies.:D

-npc

e8johan
31st May 2006, 06:23
Why don't you use QTemporaryFile ? http://doc.trolltech.com/4.1/qtemporaryfile.html

npc
31st May 2006, 06:27
Thaks for your reply,

Sorry I forgot to tell my Qt version, It is Qt 3.3 I cant find any classes like that.

-npc

munna
31st May 2006, 06:49
I think you can use QUuid for this.

npc
31st May 2006, 07:01
Thanks munna,

Is there any other way to do this apart from using UUID ?

-

munna
31st May 2006, 07:11
hmmm....

I was not able to find any other method using Qt 3. Some expert here might know a better way. Wait for their replies

wysota
31st May 2006, 08:04
You can create a "pseudorandom" filename based on current time and process id and then create a file with that name.

npc
31st May 2006, 09:37
Thank you wysota,

I used getpid() to get the process id, and used the same.

-:D