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 230 views
1 answer 166 views
166 views asked Mar 9, 2017 by avibootz
1 answer 182 views
182 views asked Aug 17, 2018 by avibootz
1 answer 148 views
148 views asked Feb 15, 2017 by avibootz
1 answer 123 views
1 answer 83 views
83 views asked Nov 6, 2022 by avibootz
...