This is a really odd security issue with a C# (3.0) Console application.
The application creates a folder and copies a bunch of files into that folder, it then also generates some files and saves them into the same folder. File streams are always closed. The copied files are done using File.Copy. Once the files are there, I don't seem to be able to access them again - later in the code, if I want to delete or open an existing file I get a access denied error yet I just created or copied the file there so I know I have permission!
Visual Studio 2008, Windows 7 (beta) - tried running as administrator but it didn't help. I also gave the parent folder permissions so that "Everyone" had write access and its under my logged in user documents folder.
Thanks!
update: I tried this on XP and had the same result so its not Win 7 :)
Have the files got the read-only attribute set? Trying to delete read-only files can cause an access denied exception to be thrown.
If you do all your stream declarations in a using block, you should be guaranteed they aren't causing the problem.
Related
I am running a vb.net application that I created. It is running in Windows 8 and the application needs to start a process. Apparently the process needs access to the c:\program files\windowsapps folder. So following the instructions I found on this site, I was able to change the owner of the folder to my ID that I use to log in and run my program with. When I run my application I still get the access denied message to that folder. When I look at File Explorer, I can now see all of the files and folders in that directory. But I can no longer get to the properties of the folder to change the settings.
How do I change the settings of that folder once I have access to it and why is my program still not able to access the folder? Is my program running as a different user? and if so, which one?
Thanks.
I am using VB.net.
I have problem with this command: Process.Start(System.Configuration.ConfigurationManager.AppSettings("ALL_ORACLEINTERFACEFILE"))
In appsetting of web.config, we found:
The problem is like this: Basically, SMSToOracleInterface.exe does two tasks:
Create a files in a local folder
Copy the files to a folder on Server.
When I double click the exe file directly, it worked well. However, when I run the web application (the application that contain Process.Start...), it did only the 1st task. 2nd task is not done at all.
Really appreciate your help.
The answer is that when we click .exe file to run, it get my window credentials to access the folder on server. Meanwhile, when we run from web application, it doesn't have credentials to access server.
How to resolve Notepad++ "Writing error summary to C:\Program Files(x86)\ ...\HTMLTIDY.ERR" on Vista pc?
I have the latest version of notepad++ (just updated it two days ago).
When I try to run TextFX htmltidy, I get the above error reported by windows vista.
I've set permissions on the file htmltidy.err to allow everyone to modify/read/write/etc.
I do not understand file permissions in Win Visa.
2nd issue: I also have to click 'Allow' whenever I click to launch notepad++ even though I granted the program exe admin rights. UAC says it is an unidentified program.
Do I need to reboot to make these changes effective? What am I missing?
This is not an error, simply a message:
Any errors found in the HTML codes are being written to this file.
For example:
line 1 column 1 - Warning: missing declaration
This is a Windows 7 restriction. Programs should not write into Program Files folder. Instead it should use a temporary folder like %TEMP% or/and %APPDATA%.
Another possible solution is to install Notepad++ outside Program Files folder, in that way you can hanle file and folder permissions by yourself.
I have a VB program that creates a temporay PDF file then opens Outlook and attaches the file. I create the file in the application path (the location that the program is running from - normally C:\Program Files\ProgamName). This works fine in XP as it appears there are no crazy permission issues. However in Windows 7, the file does not appear. There are no errors, the file does not exist in that location.
I've changed the path to the root of C:\, however this doesn't work either. I suspect it's something to do with W7 virtualisation, so the question is where can I create a file that I can then access again?
I was trying to avoid creating it on a share on a server, but it's looking like this is the only place to put it as there doesn't seem to be many places a user can write files to in Windows 7.
Surely there must be a location that users can access (without being administrators) to create files. Don't even get me started on the fun I have had with the registry in W7!!!
Thanks
Patrick
You need to create the file in the system's temp directory, which you can find by calling Path.GetTempPath().
In general, your program should only write to files in the user's Application Data (or temp) directories and only write registry keys in HKEY_CURRENT_USER. (This is true in any version of Windows)
If you follow these guidelines, you won't have any trouble in Windwos VIsta or 7.
You should never write information to places that are shared by multiple users.
Edit: While the following will work, SLaks points out it's bad practice, and the temp file won't get cleaned up.
Try %HOMEPATH% - this is the environment variable for a users documents folder, and should work no matter which version if windows you use.
In other words where you used to have:
"c:\programfiles\programname\tempFileName"
use:
"%HOMEPATH%\tempFileName"
How to Fix The Error When There Is An Error After Building The Project Dlls to Another Directory?
Error 39 Unable to copy file access is denied
For Example:
Error 1 Unable to copy file "obj\Debug\fAppCreditService.dll" to "..\..\..\..\..\2005\2005.Application\bin\fAppCreditService.dll".
The process cannot access the file '..........\2005\2005.Application\bin\fAppCreditService.dll' because it is being used by another process. fAppCreditService
I use XP
Visual Studio 2005
This error usually means that the file is inaccessible.
It is usually due to not having permissions to write to that directory, or the file being locked.
The file will be locked if an existing copy of your application is running, and the dll is in use by your application. Close any running copies of the application and re-build the solution.
If your application is not running, make sure that you have write permissions to the directory you are trying to output to.