-
September 17th, 2009, 11:22 AM
#1
[RESOLVED] Store information within program
I'm makeing a program that users will be able to have run on start up. In this program I need to create temporary files in their My Pictures folder. Unfortunatly sometimes this folder does not exist or user's profile has changed and the Evironment.user is no longer accurate. So what I would like to do is have the program check to see if the My Pictures folder exsists. If it does... wonderful. If it doesn't I have the user choose a directory where the temporary files can be created. My question is, is there a way that I can take the users chosen directory and be able to use it again next time the program starts up? I would like to do this without creating another file in which I would store the information (i.e. create a text file with the directory path in it). The reason is because the people that use this program don't have privlages to write anywhere. So I would like have the chosen directory be stored in the program if it is possible.
Thanks in advance.
- It's a long way to the top if you want to rock n' roll - AC/DC
Check out my band and support the music:
www.blueruinmusic.com
-
September 17th, 2009, 02:44 PM
#2
Re: Store information within program
You can use settings in C# to store information pertaining to the application.
Take a look at http://msdn.microsoft.com/en-us/libr...69(VS.80).aspx
-
September 17th, 2009, 04:28 PM
#3
Re: Store information within program
Why not write the temporary files in the proper location rather in the My pictures folder?
See Environment.GetFolderPath( SpecialFolder.ApplicationData );
-
September 21st, 2009, 02:29 PM
#4
Re: Store information within program
Originally Posted by Arjay
Why not write the temporary files in the proper location rather in the My pictures folder?
See Environment.GetFolderPath( SpecialFolder.ApplicationData );
Unfortunatly the users of this program do not have sufficient privlages to save files anywhere other than their documents. The reason I need to add this capability to my program is because the users name may have changed (ie. someone got married) so their log on info chaged but not how it is accessed in their my documents. I have no idea why my company would allow this but I don't care, I get paid at the end of the week regardless. Also It allows me to learn new things about programing. Hopefully that explained my needs for this a little better.
Originally Posted by Shuja Ali
I tried doing it and what I would like to do is have a string in the settings that points to "C:\\Documents and Settings\\Environment.UserName\\My Documents\\My Pictures", but it doesn't work because it doesn't make "Environment.UserName" into the users user name. Is there any way to make this work.
Thanks for the help guys.
Last edited by vandel212; September 21st, 2009 at 02:53 PM.
- It's a long way to the top if you want to rock n' roll - AC/DC
Check out my band and support the music:
www.blueruinmusic.com
-
September 21st, 2009, 03:31 PM
#5
Re: Store information within program
Originally Posted by vandel212
Unfortunatly the users of this program do not have sufficient privlages to save files anywhere other than their documents. The reason I need to add this capability to my program is because the users name may have changed (ie. someone got married) so their log on info chaged but not how it is accessed in their my documents. I have no idea why my company would allow this but I don't care, I get paid at the end of the week regardless. Also It allows me to learn new things about programing. Hopefully that explained my needs for this a little better.
As a user, I would find it irritating to discover temporary files created by some application in the My Pictures folder. It seems surprising that a company would lock down the ApplicationData folder and break the functionality of many apps.
Check out http://msdn.microsoft.com/en-us/libr...istauac_topic6
and look at the section titled Per-User Application Settings Locations.
-
September 21st, 2009, 04:06 PM
#6
Re: Store information within program
Originally Posted by vandel212
I tried doing it and what I would like to do is have a string in the settings that points to "C:\\Documents and Settings\\Environment.UserName\\My Documents\\My Pictures", but it doesn't work because it doesn't make "Environment.UserName" into the users user name. Is there any way to make this work.
Thanks for the help guys.
Code:
string path = string.Format(@"C:\Documents and Settings\{0}\My Documents\My Pictures", Environment.UserName);
===============================
My Blog
-
September 22nd, 2009, 11:51 AM
#7
Re: Store information within program
Originally Posted by eclipsed4utoo
Code:
string path = string.Format(@"C:\Documents and Settings\{0}\My Documents\My Pictures", Environment.UserName);
I'm sorry I don't understand, is this supposed to do this a design time or am I supposed to do this a run time, because putting it in the settings at design time didn't work.
Originally Posted by Arjay
As a user, I would find it irritating to discover temporary files created by some application in the My Pictures folder. It seems surprising that a company would lock down the ApplicationData folder and break the functionality of many apps.
Application Data would be a better place to save it, thanks for the tip. They didn't lock down anything in the users documents, so Application Data would still be a valid folder. Regardless I would still need to have settings to account for changed user names.
Last edited by vandel212; September 22nd, 2009 at 11:57 AM.
- It's a long way to the top if you want to rock n' roll - AC/DC
Check out my band and support the music:
www.blueruinmusic.com
-
September 24th, 2009, 03:22 PM
#8
Re: Store information within program
Originally Posted by Shuja Ali
why not just use this? Then you don't have to worry about asking the user anything. the settings file is created in the Application Data folder for the current user. It doesn't matter what their user name is vs. what the user data folder's name is.
===============================
My Blog
-
September 22nd, 2009, 11:56 PM
#9
Re: Store information within program
Originally Posted by vandel212
I. My question is, is there a way that I can take the users chosen directory and be able to use it again next time the program starts up? I would like to do this without creating another file in which I would store the information (i.e. create a text file with the directory path in it). .
try writing the folder path in registry or config file corresponding to the current user.. each time when you start up try reading this file.
-
September 24th, 2009, 12:21 PM
#10
Re: Store information within program
Here you want to save data at system level and not at user level. Then you should not store data in any of user folders. You can designate some folder, on the root path of system-drive (or other drive). User should know where exactly that is stored. Provide the details in application itself (like 'Options'), or in documentation. If you are having deployment (setup), you can ask user where the data files should be stored.
You also save the location of data files in registry, so that you can refer from that location always. If user is changed, he/she can set the data-folder using 'Options' type of UI you may provide.
-
September 24th, 2009, 01:09 PM
#11
Re: Store information within program
Originally Posted by Ajay Vijay
Here you want to save data at system level and not at user level. Then you should not store data in any of user folders. You can designate some folder, on the root path of system-drive (or other drive). ...
As much as I remembered he has told that this wasn't allowed by the firm which uses that program, or have I misduplicated what was written in an early post.
Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
September 24th, 2009, 03:19 PM
#12
Re: Store information within program
Originally Posted by Ajay Vijay
Here you want to save data at system level and not at user level. Then you should not store data in any of user folders. You can designate some folder, on the root path of system-drive (or other drive). User should know where exactly that is stored. Provide the details in application itself (like 'Options'), or in documentation. If you are having deployment (setup), you can ask user where the data files should be stored.
You also save the location of data files in registry, so that you can refer from that location always. If user is changed, he/she can set the data-folder using 'Options' type of UI you may provide.
As he stated, the user's don't have the privileges to create files outside of their user folders. and it's not something he can change.
===============================
My Blog
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
|