Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

Ari123

@Ari123
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • generating random dummy files
    A Ari123

    I would suggest a much simpler approach, using .NET Framework built-in classes... using System; using System.IO; namespace RandomFileNames { class Program { static void Main(string[] args) { //choose any folder you like, I used MyDocuments string folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); CreateRandomFiles(folder, 10); } static void CreateRandomFiles(string folderName, int numberOfFiles) { string[] extensions = { ".txt", ".exe", ".pdf", ".log", ".xls", ".doc" }; int count = extensions.Length; string fileName; Random random = new Random(); for (int i = 0; i < numberOfFiles; i++) { //this uses the static method GetRandomFileName() //of the Path class try { fileName = Path.GetRandomFileName(); //change the extension to one of your choice fileName = Path.ChangeExtension(fileName, extensions[random.Next(count)]); //create the final file name fileName = Path.Combine(folderName, fileName); //create the file itself File.Create(fileName); } catch (Exception ex) { //handle exceptions here } } } } }

    C# help question lounge
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups