473,513 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

local paths of users computer (XP vs W7)

147 New Member
Hi

My WPF (C#) application creates a new folder in the users documents folder.

There are many differences in folder structures between XP and W7. This is from the MSDN website

XP/Server 2003
ApplicationData: C:\Documents and Settings\<user name>\Application Data
CommonApplicationData: C:\Documents and Settings\All Users\Application Data
CommonProgramFiles: C:\Program Files\Common Files
DesktopDirectory: C:\Documents and Settings\<user name>\Desktop
LocalApplicationData: C:\Documents and Settings\<user name>\Local Settings\Application Data
MyDocuments: C:\Documents and Settings\<user name>\My Documents
ProgramFiles: C:\Program Files
System: C:\WINDOWS\system32

Vista/Win7/Server 2008
ApplicationData: C:\Users\<user name>\AppData\Roaming
CommonApplicationData: C:\ProgramData
ProgramFiles: C:\Program Files
CommonProgramFiles: C:\Program Files\Common Files
DesktopDirectory: C:\Users\<user name>\Desktop
LocalApplicationData: C:\Users\<user name>\AppData\Local
MyDocuments: C:\Users\<user name>\Documents
System: C:\WINDOWS\system32

So, how do I create this folder when the location is different depending on OS?

Is it best to "if else" the OS and have different rules set up depending on the OS? Should I use something similar to:
Uri u = new Uri("../Data/Basket.xml", UriKind.Relative);
and save it to a folder within my app (although I'm not sure this will work after I deploy it on multiple computers or even if it is possible)

My question is, what is the best approach? A suggestion above or other! :)

Thanks

Dave
Aug 16 '11 #1
4 3282
Christian Binder
218 Recognized Expert New Member
You could use the following
Environment.GetFolderPath(Environment.SpecialFolde r.MyDocuments);
(this returns a path-string)

There may be other useful paths in the SpecialFolder-enum.
Aug 16 '11 #2
DaveRook
147 New Member
Ha ha, I didn't realise it was under specialfolders. I had used this method for a different project and didn't think about it! D'oh.

Thank you, that has answered it
Aug 16 '11 #3
Paul Johnson
97 New Member
You also have the additional fun (if you really want to) of those running your program using Mono on a non-Windows platform ;)
Aug 16 '11 #4
DaveRook
147 New Member
Let's not complicate things :)

Actually, thankfully, I work in a small company - so I can ensure that it's PC only and only for W7, Vista and XP

Thanks all
Aug 16 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2001
by: Timothy Madden | last post by:
Hello all I'm trying to include some files in an included file. Think of some scripts like this /index.php /scripts/logging.php /scripts/config.php /scripts/db_access.php
0
1335
by: ilir | last post by:
hi everybody two problems 1. I need that user to be able to save information from textboxes of the web form to his computer. I wrote something like this fileopen(1,"c:\foldername....) this...
2
966
by: ReidarT | last post by:
I have made a tiony little program that copies file from a server to a local computer. To make this work I need to install .net framework on every computer using this exe-file. What is the...
5
3777
by: Rocky | last post by:
Hi, I have a webform, with 2 textboxs and a submit button. In the text box1, i enter a username and in textbox2 I enter the computer name. Both the username and computer name is in active...
10
5122
by: Progman | last post by:
How do you get the IP address of a computer using ASP.net? I tried Request.UserHostAddress and it does not work. I get Request for the permission of type...
1
1079
by: Manish | last post by:
Hi, I require the C# code for getting all local Window users on any machine. Can someone help me. Futher, I will need that retrieved information for logging in my Window Application. ...
4
5669
by: shashank kadge | last post by:
hi all, i am trying to get local admin users and groups on a windows server. here is the C# code that i am using...
1
1153
by: eddyman592 | last post by:
I know it is possible to read all the files from a folder on the server. Is it possible to do the same on the users computer? Say if they select a folder on their system, can you read in all the...
0
947
by: =?Utf-8?B?QW5kcmV3?= | last post by:
I have a request to add a local account (on a PC) to the Administrators Group. After adding it in manually of course when the policy with Restricted Groups kicks in this user is stripped out. Is...
0
7162
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7527
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3223
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.