HI, i'd like to develop a simple SL web page able to seek all the files of the server directory (or a client one) in order to find files containing certain strings (word or pdf or txt files) and list them in a grid or something.
How can I achieve this if I can't access the file system?
Can I use a virtual directory on iis? If yes can someone provide me few lines of code in order to retrive info from the virtual directory url (i.e. numbers of files, subfolders, and so on)
Either way it is going to require a webservice to search the file system. On the server this is not too difficult; however if you want to search the client machine this becomes a much harder solution. Though it can be done.
Off the top of my head, you can take a look at the IWeb project (http://iweb.codeplex.com/) but it is probably more complex that what you need and it built for the DotNetNuke platform.
I will try to post a simple example later today that may be more on track for what you are looking for. Do you simply want to search the website root directory and subdirectories?
Sorry I havent had time to put together a sample for your specific question yet, but thought that this code might get you pointed in the right direction:
This is the code I wrote for browsing the client (workstation) file system from Silverlight. This code is not polished AT ALL, but the general concept is there and it works. Keep in mind this is implemented as a WCF service as opposed to an ASMX service.
If you published code like this to the webserver, it would return the server file system. You would want to make sure that you restrict the root folder to that of the website.
I will still try to put together a more simplified and direct sample for you but didnt want to leave you hanging for too long. I am hoping this at least will get you started.
Thanks a lot for your interest. I will chick your code.
I'm going on trying to write a webservice to do the "seeking job" and at the moment I was successful in retriving the folders, subfolders and their contents.
I will update the post if there will be further progresses.
Efrael
Member
37 Points
30 Posts
Local search engine
Jun 08, 2009 09:27 PM | LINK
HI, i'd like to develop a simple SL web page able to seek all the files of the server directory (or a client one) in order to find files containing certain strings (word or pdf or txt files) and list them in a grid or something.
How can I achieve this if I can't access the file system?
Can I use a virtual directory on iis? If yes can someone provide me few lines of code in order to retrive info from the virtual directory url (i.e. numbers of files, subfolders, and so on)
Thanks
IT_Lackey
Member
526 Points
130 Posts
Re: Local search engine
Jun 08, 2009 10:15 PM | LINK
I am sorry do you want to search the web server or the client workstation?
Open Light Group | Silverlight Bridge | Silverlight SEO
IT_Lackey
Member
526 Points
130 Posts
Re: Re: Local search engine
Jun 08, 2009 10:18 PM | LINK
Either way it is going to require a webservice to search the file system. On the server this is not too difficult; however if you want to search the client machine this becomes a much harder solution. Though it can be done.
Open Light Group | Silverlight Bridge | Silverlight SEO
Efrael
Member
37 Points
30 Posts
Re: Re: Re: Local search engine
Jun 09, 2009 10:28 AM | LINK
Thanks,
at the moment I need to search the server, but it will be interesting to know how to achieve both the cases.
Is there some webservice example you can suggest me?
IT_Lackey
Member
526 Points
130 Posts
Re: Re: Re: Re: Local search engine
Jun 09, 2009 03:33 PM | LINK
Off the top of my head, you can take a look at the IWeb project (http://iweb.codeplex.com/) but it is probably more complex that what you need and it built for the DotNetNuke platform.
I will try to post a simple example later today that may be more on track for what you are looking for. Do you simply want to search the website root directory and subdirectories?
Open Light Group | Silverlight Bridge | Silverlight SEO
IT_Lackey
Member
526 Points
130 Posts
Re: Re: Re: Re: Re: Local search engine
Jun 09, 2009 08:47 PM | LINK
Sorry I havent had time to put together a sample for your specific question yet, but thought that this code might get you pointed in the right direction:
http://silverlightbridge.codeplex.com/SourceControl/changeset/view/53133#830727
This is the code I wrote for browsing the client (workstation) file system from Silverlight. This code is not polished AT ALL, but the general concept is there and it works. Keep in mind this is implemented as a WCF service as opposed to an ASMX service. If you published code like this to the webserver, it would return the server file system. You would want to make sure that you restrict the root folder to that of the website.
I will still try to put together a more simplified and direct sample for you but didnt want to leave you hanging for too long. I am hoping this at least will get you started.
Open Light Group | Silverlight Bridge | Silverlight SEO
Efrael
Member
37 Points
30 Posts
Re: Re: Re: Re: Re: Re: Local search engine
Jun 10, 2009 03:15 PM | LINK
Thanks a lot for your interest. I will chick your code.
I'm going on trying to write a webservice to do the "seeking job" and at the moment I was successful in retriving the folders, subfolders and their contents.
I will update the post if there will be further progresses.
IT_Lackey
Member
526 Points
130 Posts
Re: Re: Re: Re: Re: Re: Re: Local search engine
Jun 10, 2009 04:43 PM | LINK
Are you trying to search within the file content or just by filename? If you need to search content you for text files you can use this:
IF IO.File.ReadAllText(filePath).Contains(term) Then ...
But searching content across multiple file types will prove to be pretty tricky.
Don't forget that you will want to authenticate to this service so that not everyone can pull a list of your files and folders... just fyi.
Also, please be sure to mark the post as answered if it has helped.
Open Light Group | Silverlight Bridge | Silverlight SEO