skb
skb

Reputation: 31164

.NET: How to write a file with limited permissions for temporary data

I have a library I am using where the only way to pass in config data is by giving it a filename where it can go to read the data. I am writing another shared library to be used by all of our applications which consumes this, and so I need a way to store some data in a local temp folder, and then delete once I have called the shared library. Is there a simple way of doing this, without knowing the permissions that the application will have? I ma thinking IsolatedStorage because I have seen that used by ClickOnce applications, but I don't know if it allows to get the file path so I can pass it to the library.

Upvotes: 1

Views: 190

Answers (3)

Nick
Nick

Reputation: 5965

You can use Path.GetTempFileName(). This will allow you to get a temporary filename to a temp directory that your user has access to. The advantage of this over GetTempPath is that it will also generate a random file name for you.

Upvotes: 1

Nate
Nate

Reputation: 30656

You can also look at string tempPath = System.IO.Path.GetTempPath(); as the user should always have full access to that directory.

Upvotes: 1

Colin
Colin

Reputation: 10638

IsolatedStorage is basically a closed of area on the endusers filesystem. Compare it to cookies. Browsers can only store information on an end user's machine as a cookie, the browsers determines the location of the cookie storage. You can manipulate files in the isolatedstorage, but cannot go outside it.

My question, what kind of app is it (Windows, Web, Silverlight)? If it's a windows app you can basically do anything you want, since it's installed on the end user's machine.

Upvotes: 0

Related Questions