tags:

views:

2955

answers:

8

I am getting a strange error on a remote windows clients (WinForm application using C# 2.0)

Error Message: Access to the path 'c:\ApplicationFolder' is denied.

Stack Trace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)

Let me say I know I should not put the application folder directly off the c:\ folder. This an old application that I have no control over.

+5  A: 

It likely comes down to the reason that you shouldn't put the application folder there: standard users don't have write access by default. Since most people run Windows as administrator it's not often a problem, but if you try to install on a corporate environment that recently updated security policies you would suddenly have a serious problem.

Have you checked the permissions on the folder?

Joel Coehoorn
A: 

This user is an admin and has full admin rights to the folder

Please modify your question to provide additional details instead of posting answers.
Brian Rasmussen
A: 

Does the app at least load the "application folder" from a config file / the registry / a database table? If so, what happens when you change that value to something in the My Documents folder?

I saw you added the user is an admin and has full admin rights so I have to ask the obvious -- does the folder exist where the code thinks it should?

Austin Salonen
+1  A: 

A question, and a suggestion.

Does the file path reported in the message exactly match the name of the folder - letter casing, spaces, underscores, accents, everything?

Why? I've seen oddball cases where this caused a problem.

Suggestion: Use ProcessMonitor (from SysInternals, now part of Microsoft) to watch access to the folder, you'll see more details about the error - especially useful if the error reporting you're seeing isn't accurate.

Bevan
A: 

Question: Does the file path reported in the message exactly match the name of the folder - letter casing, spaces, underscores, accents, everything?

Answer: No - The real application folder name is the company name - I would perfer not to give the company name. It is a simple one word name.

Question: Does the app at least load the "application folder" from a config file / the registry / a database table?

Answer: The application loads an INI file from the 'c:\ApplicationFolder' and creates some child folder off the 'c:\ApplicationFolder' folder. Looks like the sub folder are getting create ok. Maybe it is having a problem the INI file. The database is an oracle database on another machine.

More info on the problem: The EXE is in a sub folder trying to access the parent folder 'c:\ApplicationFolder'. Example:

Application is located in 'c:\ApplicationFolder\SubFolder\SubApp.exe'

Error is getting reported when I try to access 'c:\ApplicationFolder'

Are you posting the full stack trace?
Austin Salonen
Can you post the calling code with specific company info replaced with generic terms?
Austin Salonen
Are you posting the full stack trace?I believe so - it is what the client gave me. I will double check with themCan you post the calling code with specific company info replaced with generic terms? Not sure what is the line of code in question. I will put in more detail error catch
A: 

Agree with process monitor being helpful, saved several hours of my day. Had the args to Path.Combine flipped so I ended up trying to write to the directory in lieu of the file. no hints in debug, process mon showed right up.

A: 

System.IO.FileStream.Init sounds like you're opening a file, not a folder. What is the file?

Are you sure the file exists? That it is not opened by another app? Are you trying to write to the file? Is it locked or read-only?

We need to see the code that's opening the file.

Dour High Arch
A: 

You are probably trying to get write access on read-only file.