Skip to main content

Microsoft Silverlight

Answered Question IsolatedStorageFile relative path.RSS Feed

(0)

thomasgoes
thomasgoes

Member

Member

31 points

40 Posts

IsolatedStorageFile relative path.

Is there a way I can get the IsolatedStorageFile relative path in a string? I mean the m_AppFilePath?

I don't know again what I am trying is possible or not. Here is what I want to achieve.

Say I create a Directory in IsolatedStorageFile as MyDir and create a xml file myXMLFile.xml, is it possible to do:

System.Windows.Browser;
HtmlPage.Window.Navigate(new Uri( m_AppFilePath  + " \\MyDir\\myXMLFile.xml", UriKind.Relative), "_blank");

 So user can then browse to that file in a restricted Window browser that only gives oprtion to copy or save the xml file to his own filesystem when clicked on a <TextBlock Text="Save"> on MouseLeftButtonDown event?

 IsolatedStorageFile Path is complicated path and will change based on the user. So I really want to see if I get that path and then use it to Navigate using Windows Browser that will hide the tool bar and navigation bar..so user can only see the content of the file and copy it

 

Thanks

Thomas

BoloRamji
BoloRamji

Member

Member

338 points

49 Posts

Re: IsolatedStorageFile relative path.

When  you are using HtmlPage.Window.Navigate(xxx), are you not browsing the URI on the server right? But your IsoStorage is on the client. Then your command will be of no use. Now, what you could do is to use IsoStorage in Silverlight app itself instead of in your ASP script file.

IsolatedStorageFileStream IsolatedFS = new IsolatedStorageFileStream("YourXMLFile.isf", FileMode.Open, IsolatedStorageFile.GetUserStoreForApplication());StreamReader sw = new StreamReader(IsolatedFS);

String szYourXMLString = sw.ReadToEnd();

sw.Close();

getUserResult.Text = szYourXMLString ;

Now you can  cut and paste the XML text to a notepad or something. here getUserResult is my TextBox with text wrapping=true. 

Silverlight does not have a save file dialog box. Alternatively, you can save a file on the server and use the HyperlinkButton control to download it.

You need  to store the data in the ISF  and I am wondering how you could browse the folder to select the file. If  say,

 OpenFileDialog pFileDialog = new OpenFileDialog();

//// pFileDialog.Filter = "*.isf;";

 pFileDialog.ShowDialog();

 System.IO.Stream s = pFileDialog.SelectedFile.OpenRead();

or something like that but you may already know that.

BoloRamji
BoloRamji

Member

Member

338 points

49 Posts

Answered Question

Re: IsolatedStorageFile relative path.

There is a better way to do the browsing you want. Here  is a nice sample example on msdn link:

http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile(VS.95).aspx 

 

 using (var store = IsolatedStorageFile.GetUserStoreForApplication())
  {

string subdirectory1 = Path.Combine("MyApp1", "SubDir1");

string searchpath = Path.Combine(subdirectory1, "*.*");

string[] filesInSubDirs = store.GetFileNames(searchpath);

  //you  can fill the list box with filesInSubDirs

}

You can show them in the list in silverlight for user to choose in the lay out you prefer and then follow the procedure provided in my response  to open a selected file. Then you don't need a FileOpenDialog. FileOpenDialog does not show you the  ISOStoragelocation as default and it is difficult to locate also.

let me know if you are successful in your task.

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities