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?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,368 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,234 questions
{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