Link to home
Start Free TrialLog in
Avatar of scm0sml
scm0sml

asked on

using a new guid as a file name

Hi,

Users can upload images onto my site.

However I want to rename them and give them a random name.

I wanted to create a guid that would be used as the filename.

Something like:
Dim file As String = newFileName.ToString & "." & file_ext

but when i create the file with that the name is:
00000000-0000-0000-0000-000000000000.JPG

any ideas?
Avatar of gemailj
gemailj
Flag of Egypt image

try to use this
Guid newFileName = Guid.NewGuid(); //this create a new rondom Guid
instead of
Guid newFileName = new Guid();   //this create  a zero guid doesn't calulate it

Guid newFileName = Guid.NewGuid();

Open in new window

indeed there is a ready-made method like:

Dim fn as String = System.IO.Path.GetTempFileName()
Avatar of scm0sml
scm0sml

ASKER

i cant guarentee that being unique tho can i?
 - Dim fn as String = System.IO.Path.GetTempFileName()

gemailj: is that c#? im using vb.net
ASKER CERTIFIED SOLUTION
Avatar of tasky
tasky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial