Click here to Skip to main content
15,904,153 members
Home / Discussions / C#
   

C#

 
Questioncreae directory and copy file in this directory Pin
tanzeel853-May-10 22:23
tanzeel853-May-10 22:23 
AnswerRe: creae directory and copy file in this directory Pin
Peace ON3-May-10 22:29
Peace ON3-May-10 22:29 
GeneralRe: creae directory and copy file in this directory Pin
Swiftain3-May-10 22:50
Swiftain3-May-10 22:50 
GeneralRe: creae directory and copy file in this directory Pin
tanzeel853-May-10 23:37
tanzeel853-May-10 23:37 
GeneralRe: creae directory and copy file in this directory Pin
tanzeel853-May-10 23:38
tanzeel853-May-10 23:38 
GeneralRe: creae directory and copy file in this directory Pin
Mirko19804-May-10 0:25
Mirko19804-May-10 0:25 
GeneralRe: creae directory and copy file in this directory Pin
Michel Godfroid4-May-10 2:15
Michel Godfroid4-May-10 2:15 
GeneralRe: creae directory and copy file in this directory Pin
Luc Pattyn4-May-10 2:40
sitebuilderLuc Pattyn4-May-10 2:40 
AFAIK the situation is the same on Vista and Windows 7, and will continue to be so on newer versions of Windows:
- a lot of directories cannot be modified by a regular user; those include the top-level directory of your system partition (usually C: ) and all important directories such as /Windows, /Windows/system32, and /Program Files.
- as Michel said, you need an administrator account AND an app "running as administrator" so get over those restrictions.

What should work though is access to a number of special folders intended to hold your app's settings and local data, and other things like that. Have a look at Environment.GetFolderPath() and Environment.SpecialFolder

Within such directories, one usually creates a hierarchy of folders, so a typical sequence would be:
string fileSpec=Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)+
    @"\companyName\appName\logfile.txt";
string folder=Path.GetDirectoryName(fileSpec);
Directory.CreateDirectory(folder);  // no need to test existence first!
StreamWriter writer=File.CreateText(fileSpec);
...


Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.


QuestionMessage Removed Pin
3-May-10 22:22
karayel_kara3-May-10 22:22 
AnswerRe: access parallel.for class in .net framework 3.5 sp1 and installed sp4 Pin
Mirko19804-May-10 0:08
Mirko19804-May-10 0:08 
QuestionCheck available url's ion a DNS Server Pin
Herman<T>.Instance3-May-10 22:14
Herman<T>.Instance3-May-10 22:14 
AnswerRe: Check available url's ion a DNS Server Pin
Michel Godfroid4-May-10 2:23
Michel Godfroid4-May-10 2:23 
AnswerRe: Check available url's on a DNS Server Pin
Michel Godfroid4-May-10 21:27
Michel Godfroid4-May-10 21:27 
QuestionTransparent label problem Pin
TimSWatson3-May-10 21:46
TimSWatson3-May-10 21:46 
AnswerRe: Transparent label problem Pin
Abhinav S4-May-10 0:04
Abhinav S4-May-10 0:04 
AnswerRe: Transparent label problem Pin
Dave Kreskowiak4-May-10 4:30
mveDave Kreskowiak4-May-10 4:30 
AnswerRe: Transparent label problem Pin
Johnny J.12-May-10 12:58
professionalJohnny J.12-May-10 12:58 
QuestionExpert Advice needed ACTIVEX Executable Pin
ThatsAlok3-May-10 21:29
ThatsAlok3-May-10 21:29 
QuestionHo to get the IP address of Network Printer. Pin
deadlyabbas3-May-10 20:36
deadlyabbas3-May-10 20:36 
AnswerRe: Ho to get the IP address of Network Printer. Pin
Abhinav S3-May-10 20:43
Abhinav S3-May-10 20:43 
QuestionNew Project Ideas? (Working on mobile Banking) Pin
CoderForEver3-May-10 19:54
CoderForEver3-May-10 19:54 
AnswerRe: New Project Ideas? (Working on mobile Banking) Pin
Peace ON3-May-10 21:13
Peace ON3-May-10 21:13 
QuestionTextboxs binding to member variables Pin
Vijjuuu.3-May-10 19:44
Vijjuuu.3-May-10 19:44 
AnswerRe: Textboxs binding to member variables Pin
Gerry Schmitz3-May-10 21:17
mveGerry Schmitz3-May-10 21:17 
GeneralRe: Textboxs binding to member variables Pin
Vijjuuu.3-May-10 21:19
Vijjuuu.3-May-10 21:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.