Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.NET

Posted on 2010-08-24
19
Medium Priority
?
382 Views
Last Modified: 2013-11-27
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.
0
Comment
Question by:spatel208
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 4
19 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 33508927
What os are you using ?
What folder do you try to use ?
0
 

Author Comment

by:spatel208
ID: 33508956
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.
0
 
LVL 4

Expert Comment

by:GO-87
ID: 33508962
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?
 
0
AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

 
LVL 4

Expert Comment

by:GO-87
ID: 33508971
OK, your app needs to have elevated rights to access the other users' folders
 
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33508980
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(Environment.SpecialFolder.ApplicationData)
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33508986
0
 

Author Comment

by:spatel208
ID: 33509014
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
0
 

Author Comment

by:spatel208
ID: 33509071
HI Dhaest,

Thank you, I tried  to use the link which you have given, It is not admin user
Please advise.

thanks
0
 

Author Comment

by:spatel208
ID: 33509078
I tried to run VS as Administrator but having the same result. Please help me out of this.

Thank you.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33509100
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

0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33509104
0
 

Author Comment

by:spatel208
ID: 33509130
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\Debug' is denied.

When program run the following line.

FS = New FileStream(Location, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)
0
 

Author Comment

by:spatel208
ID: 33509187
Hi Dhaest,

It is still same , I have tried app.mainfest file and placed in the same location. but no joy.

thanks
0
 
LVL 4

Expert Comment

by:GO-87
ID: 33509421
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\Debug\MyFile.txt
0
 

Author Comment

by:spatel208
ID: 33509454
Yes It works.. Thank you

Thank you all of you, for giving me the suggestion.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33509549
What exactly did you now do to let it work ?
Adding the elevation or changed the path ?
0
 
LVL 4

Expert Comment

by:GO-87
ID: 33518726
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
0
 

Author Comment

by:spatel208
ID: 33552646
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?
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 total points
ID: 33556144
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question