Link to home
Start Free TrialLog in
Avatar of eladr
eladr

asked on

Random number

im looping on some directory and every "gif" or "jpg" i rename the file to random number.
the problem is that my random number is always the same number...

10x


foreach (string filename in Directory.GetFiles(DirPath))
                        {
                              OldFileName = GetFileNameFromFullPath(filename);
                              exts = OldFileName.Split('.');
                              if(exts[1].ToString().ToLower() == "jpg" || exts[1].ToString().ToLower() == "gif" || exts[1].ToString().ToLower() == "jpeg")
                              {
                                    Random R = new Random();
                                    newFileName = R.Next(100000) + "." + exts[1];
                                    File.Move(DirPath + "\\" + OldFileName,DirPath + "\\" + newFileName);
                              }
                        }
ASKER CERTIFIED SOLUTION
Avatar of acharbonneau
acharbonneau

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