Skip to main content

Microsoft Silverlight

Answered Question Environment.CurrentDirectory --> is resulting errorRSS Feed

(0)

anil_litam
anil_litam

Member

Member

558 points

262 Posts

Environment.CurrentDirectory --> is resulting error

Hi,

i am try to get my silverlight application total path using Environment.CurrentDirectory.

I written this code in xaml.vb file resulting runtime errors.

PLease suggest me what is the problem and solution for this...

ken tucker
ken tucker

All-Star

All-Star

16288 points

2,485 Posts

Re: Environment.CurrentDirectory --> is resulting error

You only have access to isolated storage from silverlight 2. 

anil_litam
anil_litam

Member

Member

558 points

262 Posts

Re: Environment.CurrentDirectory --> is resulting error

anil_litam
anil_litam

Member

Member

558 points

262 Posts

Re: Environment.CurrentDirectory --> is resulting error

OK. Can you please suggest me how can i get my SL application path using ISOLATED STORAGE

I am using SL3

Thanks...

Tim Dawson
Tim Dawson

Participant

Participant

1130 points

218 Posts

Re: Environment.CurrentDirectory --> is resulting error

Your application path is a website. You can use the browser interop APIs to get its path or in fact interact with the whole HTML DOM.


Microsoft MVP
Controls for Silverlight, WPF and Windows Forms at http://www.divelements.co.uk

anil_litam
anil_litam

Member

Member

558 points

262 Posts

Re: Environment.CurrentDirectory --> is resulting error

 For ex: My application path is c:\SLTest\page.xaml

I would like to get the path c:\SLTest

For this i don't want to make any API calls.

Because i am writing the code in XAML page(client page) and also my application is in local drive.

How can i get this path using XAML page code.

Thanks...

 

ken tucker
ken tucker

All-Star

All-Star

16288 points

2,485 Posts

Re: Re: Environment.CurrentDirectory --> is resulting error

Silverlight runs in a sandbox.  You do not have access any part of the file system other than the isolated storage.  You do not have access to any api calls. 

 

Silverlight 3 has a save file dialog but the user has to select where to save a file no have no control over where the file is saved.  The user has to press ok in the dialog or there is no way to save a file with the save file dialog

anil_litam
anil_litam

Member

Member

558 points

262 Posts

Re: Re: Environment.CurrentDirectory --> is resulting error

 Please give the basic links to understand about sandbox and

i am not looking for any savefiledialog, but i don't think so getting my local application path is that much difficult. {Because i am not looking for any server access)

Thanks for your suggessions...

Tim Dawson
Tim Dawson

Participant

Participant

1130 points

218 Posts

Re: Re: Environment.CurrentDirectory --> is resulting error

Silverlight apps run on the web. There's no API for obtaining a "local" path. Even if you run it locally, you're still running in a browser, client-side. Refer to my previous post for how you can obtain the URL to the page hosting the app.


Microsoft MVP
Controls for Silverlight, WPF and Windows Forms at http://www.divelements.co.uk

ken tucker
ken tucker

All-Star

All-Star

16288 points

2,485 Posts

Re: Re: Re: Environment.CurrentDirectory --> is resulting error

http://en.wikipedia.org/wiki/Sandbox_(security)

anil_litam
anil_litam

Member

Member

558 points

262 Posts

Re: Re: Re: Environment.CurrentDirectory --> is resulting error

Though i am using SL from past 4 months, still i don't know what is sandbox.

 Thanks for the link.

anil_litam
anil_litam

Member

Member

558 points

262 Posts

Re: Re: Environment.CurrentDirectory --> is resulting error

Ok. Thanks for good replys.

So, can you tell me how can i access c:\\test.xml file, without directly adding it onto my application.

As per your reply i think there is no option.

Am i right?   OR   please suggest me how can i achieve this using Isolated Storage.

Thanks once again...

Tim Dawson
Tim Dawson

Participant

Participant

1130 points

218 Posts

Re: Re: Environment.CurrentDirectory --> is resulting error

Correct; there is no way you can access c:\test.xml. The file would have to be in isolated storage or part of the application. Unless Silverlight considers files in the same directory as the application to be part of the site of origin, that is. I don't understand why you're even using Silverlight if you're trying to create a client application.


Microsoft MVP
Controls for Silverlight, WPF and Windows Forms at http://www.divelements.co.uk

anil_litam
anil_litam

Member

Member

558 points

262 Posts

Re: Re: Environment.CurrentDirectory --> is resulting error

 Thanks for your interest to chase me.

Might i didn't explain clearly.

My SL application is in c:\SLTest directly.

So obviously i can get two folder sunder SLTest folder. They are SLTest and SLTest.Web and also SLTest solution file.

In the root SLTest folder i added one more folder 'MyXml' which is having "First.XML"

My only requirement is i should be access this "First.XML" from my XAML code, with out adding it into my application [solution explorer right click -->  add existing item --> select this xml] i don't want this approach to do.

Moreover i am developing a tool not direct application.

Very thanks...

 

 

ken tucker
ken tucker

All-Star

All-Star

16288 points

2,485 Posts

Answered Question

Re: Re: Environment.CurrentDirectory --> is resulting error

 I would add the xml file to the website's clientbin folder.  This thread shows how to access the file

http://silverlight.net/forums/p/99312/226675.aspx

Tim Dawson
Tim Dawson

Participant

Participant

1130 points

218 Posts

Re: Re: Environment.CurrentDirectory --> is resulting error

Why are you using Silverlight and not WPF?

 


Microsoft MVP
Controls for Silverlight, WPF and Windows Forms at http://www.divelements.co.uk

anil_litam
anil_litam

Member

Member

558 points

262 Posts

Re: Re: Environment.CurrentDirectory --> is resulting error

 I am developing a tool, so i can't add xml files to clientbin which are required for end application.

i don't know how many xml files i required once the product over...

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities