spatel208
asked on
VB.NET
hi, I am using VS 2008 and try to use FS but getting error access denied to application folder to create file using the following line. where the Location is Application Folder.
FS = New FileStream(Location, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)
I am getting the error "Access to path " [Location] " is denied."
Please help.
FS = New FileStream(Location, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)
I am getting the error "Access to path " [Location] " is denied."
Please help.
ASKER
IT VISTA, and it is bin\debug under the project folder from VS and it will be Application folder for the other users.
thank you for quick response.
thank you for quick response.
spatel208, it sounds like you don't have permission to the folder it's trying to use.
That could be as a result of the folder not being the one you thought it was, or perhaps that the "account" your application is using has insufficient privileges.
This can happen on Vista for example if you're trying to access say C:\ root and you're not using an account with sufficient rights.
Perhaps you could experiment by changing the location to something simpler, or to something you KNOW you have access to?
That could be as a result of the folder not being the one you thought it was, or perhaps that the "account" your application is using has insufficient privileges.
This can happen on Vista for example if you're trying to access say C:\ root and you're not using an account with sufficient rights.
Perhaps you could experiment by changing the location to something simpler, or to something you KNOW you have access to?
OK, your app needs to have elevated rights to access the other users' folders
I would suggest to store the application data in the "specialfolder" and no longer in the c:\program files
See also this article: http://www.developingfor.net/vista/vista-and-special-folders.html
Environment.GetFolderPath( Environmen t.SpecialF older.Appl icationDat a)
See also this article: http://www.developingfor.net/vista/vista-and-special-folders.html
Environment.GetFolderPath(
VB.NET How to tell if a user can elevate to admin rights in Vista and Windows 7
http://zerosandtheone.com/blogs/vb/archive/2009/07/29/vb-net-how-to-tell-if-a-user-can-elevate-to-admin-rights-in-vista-and-windows-7.aspx
http://zerosandtheone.com/blogs/vb/archive/2009/07/29/vb-net-how-to-tell-if-a-user-can-elevate-to-admin-rights-in-vista-and-windows-7.aspx
ASKER
Well I tried to access "C:\Test" folder and I am having Administrator rights to C: drive, but still I am getting the same problem.
Thanks
Thanks
ASKER
HI Dhaest,
Thank you, I tried to use the link which you have given, It is not admin user
Please advise.
thanks
Thank you, I tried to use the link which you have given, It is not admin user
Please advise.
thanks
ASKER
I tried to run VS as Administrator but having the same result. Please help me out of this.
Thank you.
Thank you.
It will be very hard. I would recommand to use another directory
Inside Windows Vista User Account Control
http://technet.microsoft.com/en-gb/magazine/2007.06.uac.aspx
The COM Elevation Moniker
http://msdn.microsoft.com/en-us/library/ms679687.aspx
How to UAC elevate a COM component with .NET
http://stackoverflow.com/questions/127042/how-to-uac-elevate-a-com-component-with-net
Inside Windows Vista User Account Control
http://technet.microsoft.com/en-gb/magazine/2007.06.uac.aspx
The COM Elevation Moniker
http://msdn.microsoft.com/en-us/library/ms679687.aspx
How to UAC elevate a COM component with .NET
http://stackoverflow.com/questions/127042/how-to-uac-elevate-a-com-component-with-net
Making a .NET app run on Vista with Administrator priviledges
http://www.developerfusion.com/code/7987/making-a-net-app-run-on-vista-with-administrator-priviledges/
http://www.developerfusion.com/code/7987/making-a-net-app-run-on-vista-with-administrator-priviledges/
ASKER
Thank yu Dhaest, Can you please tell me, which user I need to give access, I have given access to Everyone as Full Control on this folder.
The Error is : Access to the path 'C:\MyData\My Projects\LocumNav\bin\Debu g' is denied.
When program run the following line.
FS = New FileStream(Location, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)
The Error is : Access to the path 'C:\MyData\My Projects\LocumNav\bin\Debu
When program run the following line.
FS = New FileStream(Location, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)
ASKER
Hi Dhaest,
It is still same , I have tried app.mainfest file and placed in the same location. but no joy.
thanks
It is still same , I have tried app.mainfest file and placed in the same location. but no joy.
thanks
Spatel208, is it possible you're specifying a folder path when you should be specifying a specific filename?
e.g. C:\MyData\My Projects\LocumNav\bin\Debu g\MyFile.t xt
e.g. C:\MyData\My Projects\LocumNav\bin\Debu
ASKER
Yes It works.. Thank you
Thank you all of you, for giving me the suggestion.
Thank you all of you, for giving me the suggestion.
What exactly did you now do to let it work ?
Adding the elevation or changed the path ?
Adding the elevation or changed the path ?
Good morning, Spatel208
If everything is working now, please be so kind as to answer Dhaest's question, and then award points accordingly.
Thank you
GO-87
If everything is working now, please be so kind as to answer Dhaest's question, and then award points accordingly.
Thank you
GO-87
ASKER
I was not adding the filename in the path and also I have given rights to everyone with full control to the target directory.
I am sorry, but I am new to the family and I don't know how to award the points to experts.
Can any one suggess me?
I am sorry, but I am new to the family and I don't know how to award the points to experts.
Can any one suggess me?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What folder do you try to use ?