Ian Ringrose
Ian Ringrose

Reputation: 51927

Using .Net, how do I create a temp file that is readable by ALL processes?

When I use

Path.GetTempFileName();

It creates a file in the current user’s profile that is readable by the current user; however the file can’t be read by all services on the machine. (As services run under their own accounts.)

I need to pass the path of the newly created file to a service running on the same machine, then that services has to read its contents (don’t ask why!).

So I am just looking for a way to create a system-wide temp file without assuming the layout of the machines disks.

Upvotes: 0

Views: 99

Answers (1)

rene
rene

Reputation: 42494

You can use

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

And generate/create a file there.

Reference to the Enumeration.SpecialFolder and the GetFolderPath documentation at MSDN.

Upvotes: 1

Related Questions