Introduction

Usually a Silverlight application is not allowed to access a FileInfo's full path attribute, even via reflection. This is because of the security policy.

But sometimes, for our applications, we need to store a file's path, especially if talking about network directories. To workaround this, we can use JavaScript! Honesty I hate JavaScript, but sometimes there is no other way. Silverlight is even too much secure for production applications!

The basic idea is to grant access to path by using JavaScript and then send back the value to Silverlight for our use.

Note

This solution will perfectly work on Internet Explorer, will only show file name on Firefox and won't work on Chrome, because of Input element implementation... :@ If you have any solution to this, please report it to me and I will update this tip page!

Background

Please refer to this article if you don't know how Silverlight/JavaScript communication works.