You all know that, Silverlight 4 has the feature to talk with COM APIs. In my earlier posts I already mentioned various Interoperability functionalities of Silverlight. You can see some articles in my Blog. In this article, I will show you how Silverlight can read your local files, folders and drives. At the end of this Article you will be able to open any file/folder/drive and read their attributes. Here I will demonstrate by creating a small application like Windows Explorer and reading all your drives and their contents in the screen like below screenshot:
You will be able to open the drive and browse through it’s contents (subfolders and files). Interesting? So, read it out and learn Silverlight 4 a bit more. Don’t forget to leave your comments at the end. Table of ContentsBackground
Basic knowledge on the API
Prerequisite
Setting up Project
Configure Application for Out-of-Browser Support
Configure Application for “dynamic” keyword Support
Play with the XAML
Create the basic UI
Create the Template for drive selector
Create the Template for folder browser
Implementing Code
Create the basic classes
Create Dependency Properties
Implementing GetDriveInfo() method
Implementing GetFolders() method
Implementing GetFiles() method
Integration of API calls to the page
What Next?
Download
End Note
You will be able to open the drive and browse through it’s contents (subfolders and files). Interesting? So, read it out and learn Silverlight 4 a bit more. Don’t forget to leave your comments at the end. Table of ContentsBackground
Basic knowledge on the API
Prerequisite
Setting up Project
Configure Application for Out-of-Browser Support
Configure Application for “dynamic” keyword Support
Play with the XAML
Create the basic UI
Create the Template for drive selector
Create the Template for folder browser
Implementing Code
Create the basic classes
Create Dependency Properties
Implementing GetDriveInfo() method
Implementing GetFolders() method
Implementing GetFiles() method
Integration of API calls to the page
What Next?
Download
End Note
BackgroundEarlier to Silverlight 4, we are able to only get file access to some of the location of your Windows Operating System like My Documents. In new version of Silverlight i.e. in Silverlight 4 you can able to access any files and/or folders. Not only this, you can able to get information of any drive, files and folders. Though there is a restriction to run the Silverlight application in Out-of-Browser mode, but it actually benefited for those who want to run it outside browser. Accessing your local drive, files and folders are achievable using the COM Interoperability which Silverlight 4 supports. Using the COM API call you can get all the drives attached to your PC, read the Drive Information i.e. total size, free space etc., read the files, folders and subfolders of any drive, run any application or file, do a copy/move/delete/rename operation on any file, folder or drive. Here in this article we will see some of the operations like reading your local drive, files and folders and displaying them inside the Silverlight OOB Application.Basic Knowledge on the APILet us first discuss about the basic API functionalities require to develop this application. To do this, we need to create the object of “Scripting.FileSystemObject” from the “AutomationFactory”. It has several properties and methods to read files, folders and drives information from your local PC. Read more: Kunal's Blog
0 comments:
Post a Comment