How to generate random file name with windows temp path in C#

1 Answer

0 votes
using System;
using System.IO;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string tempPath = Path.GetTempPath();

            string randomFileName = Path.GetRandomFileName();

            string s = Path.Combine(tempPath, randomFileName);

            Console.WriteLine(s);
        }
    }
}


/*
run:

C:\Users\Avi\AppData\Local\Temp\3s0bf41g.i0w

*/

 



answered Mar 9, 2017 by avibootz

Related questions

1 answer 242 views
1 answer 176 views
176 views asked Mar 9, 2017 by avibootz
1 answer 192 views
192 views asked Aug 17, 2018 by avibootz
1 answer 142 views
1 answer 135 views
135 views asked Jan 24, 2017 by avibootz
...