how to create temp and archive folder in .net

Suleyman Sirkinti 21 Reputation points
2023-01-09T10:59:23.657+00:00

I want to create temp and archive folder. The most commonly used "Path.GetTempPath()" function. But there is a problem for me. gettemppath gives only path, i want it to create a temp folder where the exe is located. How can i do that?

Developer technologies .NET Other
Developer technologies C#
{count} votes

Accepted answer
  1. Zsolt Hajdu 156 Reputation points
    2023-01-10T13:40:15.233+00:00

    Directory.CreateDirectory is enough, you don't need to check if it's exists or not

    Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Temp"));
    

    https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.createdirectory?view=net-6.0

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.