Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > .NET Framework 1.x
|
.NET Framework 1.x For discussing versions 1.0 and 1.1 of the Microsoft .NET Framework.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 1.x section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 6th, 2006, 03:56 PM
Registered User
 
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access Denied Error in WinForms App

Hi,

I have created a WinForms app that needs to save a file to my hard
drive.

Whenever I try to save a file I recieve an "access to the path <my
path> is denied" error.

I have used the .Net configuration wizard to check the permissions
granted to my assembly. The wizard reports the assemble has
"unrestricted" rights.

I have tried to save to "My Documents", Desktop and the bin of the apps
directory with the same results.

I have checked the permissions on c drive and "Everyone" is set to full
access.

I have tried other applications and i have created a new application
and I recieve the same error message.

Something has changed as I used to be able to write to the c: drive
with no problems. I do not know what I have done to cause this.

I have found plenty of topics about this error for Asp.Net but not for
Windows Forms. I don't think the Asp.Net issue applies to me.

What do you think? Any ideas on whats going on?

 
Old September 7th, 2006, 11:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Are you running this app from a shared folder on network.
If not, the location from where you are running it, try checking
the permissions granted to your app using caspol utility's rsg and rsp
switches. If your file writing code is in a seperate assembly that
your application loads, check the permissions granted to that assembly
seperately. Do write back if you r still feeling lost, this certainly
is not a case of .NET having any grudges against you.

Regards
Ankur
 
Old September 7th, 2006, 04:04 PM
Registered User
 
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response.

I was able to find my problem. I was drilling to the path of the file but leaving out the name of the file itself. (SLAP as he hits his forhead with the palm of his hand)
Here is the code where I goofed (with Hello World substituted for the actual string value).
<code>
                Dim fw As StreamWriter
                Dim FilePath As String = "c:\" ' Here was the problem
               '(solution = "c:\testfile.txt")
                fw = New StreamWriter(FilePath, True)

                fw.Write("Hello World")

                fw.Close()
</code>

Thanks for your reply it started the process that lead to me finding where I goofed!



 
Old September 8th, 2006, 01:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

You are always welcome Scott.

Regards
Ankur





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Access Denied Error hkccwong Classic ASP Basics 6 January 11th, 2008 04:12 AM
how to avoid access denied error satyakishore Javascript 1 March 29th, 2006 01:48 PM
'Access is denied' error purvin Javascript 4 March 22nd, 2006 04:42 AM
access denied in thePhile app C# version sample mkamoski Wrox Book Feedback 2 August 30th, 2005 06:49 AM
please.....urgent....."access denied error while s Ramakrishna General .NET 2 October 12th, 2004 12:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.