|
-
Apr 25th, 2008, 01:56 PM
#1
Thread Starter
Lively Member
DirectoryInfo.GetDirectories() not working properly in .net 1.1
(language C#)
When I use this code:
DirectoryInfo drInfo = new DirectoryInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites));
DirectoryInfo[] subDrInfo = drInfo.GetDirectories();
if (subDrInfo.Length > 0)
subDirInfo.Length returns 1 which is not true
When I use
DirectoryInfo drInfo = new DirectoryInfo(@"C:\Documents and Settings\myUserName\Favorites");
DirectoryInfo[] subDrInfo = drInfo.GetDirectories();
if (subDrInfo.Length > 0)
subDirInfo.Length returns 3 which is correct
But I have to use Environment.SpecialFolder.Favorites instead of giving full path of the folder. The same code works fine in .net 2.0 . Any help please?
-
Apr 26th, 2008, 06:08 AM
#2
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
When debugging, is
System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites)
the same as
C:\Documents and Settings\myUserName\Favorites
?
-
Apr 28th, 2008, 10:47 AM
#3
Thread Starter
Lively Member
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
I thought it is the same. but for my surprise when I debug the path is like:
C:\Documents and Settings\myComputerName\ASPNET\Favorites (when I run from VS 2003)
when I run the application from VS 2005 then it is going to:
C:\Documents and Settings\myUserName\Favorites
Thanks for the question Mendhak...
How can I get User's Favorites?
-
Apr 28th, 2008, 11:07 AM
#4
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
Well this is a Web Application. It doesn't seem to make sense why you'd want to set the favorites on the server machine unless everything is setup through AD and the web application impersonates each user that logs in (so it would be able to modify their favorites on roaming profiles).
Why do you need to modify the server's favorites? Remember, you can't get the user's favorites (that would be a large security and privacy risk) unless you're in a setup where everything in hooked into AD, the site impersonates each user and the computer profiles are setup so favorites travel with the logins.
-
Apr 28th, 2008, 11:40 AM
#5
Thread Starter
Lively Member
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
Actually I wanted to read Favorites links from the logged in user's browser and add them to a sharepoint portal list. So I am lloking for Client machines' Favorites but not of the server.
-
Apr 28th, 2008, 12:15 PM
#6
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
You can't read the user's favorites using server side code. It was curious to see you reading the Favorites folder on the server.
I won't make the ActiveX/Java applet suggestion to you either about this as it counts as invasion of privacy. I don't want any application or any person knowing about my bookmarked belly-button lint websites.
-
Apr 28th, 2008, 12:15 PM
#7
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
You can't read the user's favorites using server side code. It was curious to see you reading the Favorites folder on the server.
I won't make the ActiveX/Java applet suggestion to you either about this as it counts as invasion of privacy. I don't want any application or any person knowing about my bookmarked belly-button lint websites.
-
Apr 28th, 2008, 01:12 PM
#8
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
Of course if it's an intranet with AD authentication you can use impersonation and roaming profiles to possinly get the user's favorites but that's a pain in the ass. Why do they have to be in SharePoint? Why can't the users have their own favorites and collaborate on others?
A better solution may be utilizing Firefox and their custom software that allows you to store favorites remotely. You may be able to use that to collaborate.
-
Apr 28th, 2008, 01:50 PM
#9
Thread Starter
Lively Member
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
The actual requirement is:
there is a webpart in the portal home page "My Links" which shows the user's favorites links in his/her browser and allows the user to click on the link to get that page. It's an intranet portal.
Is there any clientside code for this or any other way?
-
Apr 28th, 2008, 02:14 PM
#10
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
 Originally Posted by kiran_q8
The actual requirement is:
there is a webpart in the portal home page "My Links" which shows the user's favorites links in his/her browser and allows the user to click on the link to get that page. It's an intranet portal.
Is there any clientside code for this or any other way?
There are only two ways of doing this that I can think of:
1. Like I've mentioned a few times before, if AD supports this (and I don't know that it does) and your intranet is authenticating through AD then you may be able to use impersonation, have the website impersonate as the user who's browsing the page, and grab their bookmarks from their roaming profile. Kind of odd but if favorites are setup via AD to travel with the user and you're using AD authentication then I don't see why it wouldn't be possible.
2. Write an ugly ActiveX object, install it onto each user's machine and somehow sync between Sharepoint and the user's account. Pretty ugly but it can work (it'll only work with IE though).
There is simply no way of doing this with client side code otherwise every website you visit would have all of your favorites which would be a huge security issue as well as a privacy issue.
Honestly, this is a very odd requirement so you may want to verify that your client understands the disconnect between client and server and the security / privacy protections that are in place. Either solution you make may not be compatible with any browser but IE.
-
Apr 28th, 2008, 02:35 PM
#11
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
Its not totally odd.. Many online link services (like favorites.live.com, or the google based one) will read the local links from your browser in order to migrate them to the online service. So I have seen totally valid uses for something like this.
It was nice to see when I moved to an online service based link repository, I didn't have to re-enter the many favorites I had cached locally.
And at the risk of actually pimping an MS live service, their favorites service is way better than googles, and I really enjoy using it.
-
Apr 28th, 2008, 02:53 PM
#12
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
In this case, you don't want to read files, instead you need Properties of those files. If you open Favorites folder in your system, which is:
C:/Documents and Settings/username/Favorites
you will find Internet Shortcuts, and not valid Text files or HTML files.
You can create object of FileSystemObject as an ActiveXObject in JavaScript and can read files.
You ought to know 2 things:
- This can be an invasion of privacy.
- This will work only in Internet Explorer.
MSDN - FileSystemObject Basics
-
Apr 28th, 2008, 03:11 PM
#13
Re: DirectoryInfo.GetDirectories() not working properly in .net 1.1
 Originally Posted by kleinma
Its not totally odd.. Many online link services (like favorites.live.com, or the google based one) will read the local links from your browser in order to migrate them to the online service. So I have seen totally valid uses for something like this.
Typically those are plug-ins where as this is a run-at-the-site kind of thing. I would say write a plug-in to do exactly what you want rather than rigging a site to do it when you visit it (like the current suggestions / methods).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|