Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8280905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:51:02+00:00 2026-06-08T09:51:02+00:00

Im using C# and my code is reading and moving some files. The problem

  • 0

Im using C# and my code is reading and moving some files. The problem is, that there are not so many files to read and move them to other folders. But I would like to test my code with 500,1000 or more files at once.

I could create every single file by myself -> not so smart. I could generate these files and write my own code for this -> could work, but is there not an easier way? Maybe there are already some tools for developers to create testfiles? Or is there another solution in c#/.net?

PS: Ah forgot to say – Im reading normal ascii file. Later I would like to create “csv-like” files (strings splittet by “;”) if it would be possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:51:03+00:00Added an answer on June 8, 2026 at 9:51 am

    This code will create an arbitrary number of files, each with an arbitrary number of lines, each containing an arbitrary number of comma-separated random integer values.

    I hope it gets you started on creating some test data for your application.

        static void Main(string[] args)
        {
            int numFiles = 30;
    
            for (int fileIndex = 0; fileIndex < numFiles; fileIndex++)
            {
                string randomFileName = Path.Combine(@"c:\temp", Path.GetRandomFileName() + ".csv");
    
                GenerateTestFile(randomFileName, 20, 10);
            }
        }
    
        static void GenerateTestFile(string fileName, int numLines, int numValues)
        {
            int[] values = new int[numValues];
    
            Random random = new Random(DateTime.Now.Millisecond);
            FileInfo f = new FileInfo(fileName);
    
            using (TextWriter fs = f.CreateText())
            {
                for (int lineIndex = 0; lineIndex < numLines; lineIndex++)
                {
                    for (int valIndex = 0; valIndex < values.Length; valIndex++)
                    {
                        values[valIndex] = random.Next(100);
                    }
    
                    fs.WriteLine(string.Join(",", values));
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a plist file using code below. My problem is that the
I have been reading that creating dependencies by using static classes/singletons in code, is
update SOLVED - the problem is not with my code. there is a design
With the following file reading code: using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read,
I'm using gdata-python-client to read data from a Google spreadsheet. My code for reading
How can i go about using bar code reading capabilities with my S60 application?
i am reading an excel file using this code i found over the net:
I am reading javascript web application and the author is using following code: mod.load
I'm reading a csv file using c# here is a little code snippet. using
In my code, I am using several file reading using RandomAccessFile . I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.