user569574
user569574

Reputation: 99

change file name Isolated Storage windows phone 7

i would like when i create a file in the IO by using the StreamWriter something like

streamReaderLOL = new StreamReader(
  new IsolatedStorageFileStream("test\\parameter.txt", FileMode.Open, UserPlace)); 

where parameter is a variable i have try smth like

"test\\"+parameter".txt" etc but seems not to work.

so my question is : is it possible ?

ty a lot

Upvotes: 0

Views: 468

Answers (2)

Matt Lacey
Matt Lacey

Reputation: 65564

If you want to use a directory within IsolatedStorage you must first create the directory before trying to use it.

using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
    if (!isoStore.DirectoryExists("test"))
    {
        isoStore.CreateDirectory("test");
    }

    isoStore.CreateFile("test\\" + param + ".txt");
}

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1500375

Using "test\\" + parameter + ".txt" should be absolutely fine. It's only constructing a string to pass in as the arugment, after all.

Upvotes: 1

Related Questions