Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# directory to "play with"

Tags:

c#

windows

Simple question here. I have a C# program which needs to stores some files onto the hard drive, but I don't need them to be anywhere useful to the end-user, only somewhere that the program can read/write from.

Is there a directory that I can reference programmatically to be my "filespace playground" - that is, that I can read/write freely to and from?

EDIT: Also, if I use a temp directory, how long are the files guaranteed to be there? I don't want the them to disappear while my program is still running!

like image 756
Adam S Avatar asked Jan 19 '26 15:01

Adam S


1 Answers

I would use the Application Data Directory. You can get to it using something like:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

It is the prefered location in windows for application specific data and it is generally hidden from the user unless they would like to go and find it.

like image 69
Tim C Avatar answered Jan 22 '26 04:01

Tim C