creae directory and copy file in this directory
-
hi all...i have to create directory in win7 and copy file in this directory programmatically in using c#..my application properly work in winXP...but when i run my application in win7..it does not create directory as well as copy file...tell me what i do for win7....it is a C# windows desktop application... regards tanzeel
-
hi all...i have to create directory in win7 and copy file in this directory programmatically in using c#..my application properly work in winXP...but when i run my application in win7..it does not create directory as well as copy file...tell me what i do for win7....it is a C# windows desktop application... regards tanzeel
-
In win7 you need to give admin access (or you need to run your windows application as an administrator) to your application to allow it to create directory. Hope this will help!
Jinal Desai - LIVE Experience is mother of sage....
-
In win7 you need to give admin access (or you need to run your windows application as an administrator) to your application to allow it to create directory. Hope this will help!
Jinal Desai - LIVE Experience is mother of sage....
-
Logging in is not enough to be an administrator. You should run your program as administrator. Also if your program does not give your an error message, it's probably because you aren't checking for any errors. (boo! boo!). If it fails to create a directory, you should not be creating your directory there in the first place (Places like the root of c:, program files, windows, etc... are taboo.
-
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()
andEnvironment.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); ...
:)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.