Access Denied when writing to a file.can you help?

Hi guys,
Despite several pages on goggle on "access denied" I have not found a proper solution.

I have a vb.net project 2005
I have created a folder called "c:\Test"

then I m trying to create a file in this folder and I get "access is denied"

Could somebody give me a walkthrough or what permission and where i need to have and how to enable them.

The funny thing is it doesnt happen on another folder?!? mmmm

I cannot see a difference

Can you help?

thanks a lot

[490 byte] By [vbjunkie] at [2007-12-16]
# 1
"Access denied" can mean several things, like insufficient permission, or the file you're trying to write/create is already existing and is in used by others, or the file simply is locked.

Can you provide us more information about the error, like the stack trace?

-chris

gwapo at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 2

Hi,

In addition, are you logged on as an administrator? Are you part of a Network? If your part of the network, take alook at the properties of the folder on its permissions. See if the user that you are using is permitted to access the folder...

cheers,

Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 3

I have tested both on my laptop logged as administrator and at work
I have looked in
admistrative tools
Computer Management
Local Users and groups
and myself is a member of
"Administrators"
Debugger Users
Users

I have also unchecked the readonly on the folder but after apply and go back it's there again
Is there a permission "write to folders"


I am trying to create an xml file in a newly created folder in an windows app using vb.net 2005

What do I need to do?

vbjunkie at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 4

Hi,

Are you trying to create the file manually? Or pragmatically? If so, could you post the code on how you create the xml file in vb.net?

cheers,

Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 5

Thanks for your quick reply

the actual error i get is "access to path 'c:\test' denied
For testing I created a form with a button and textbox multiline.

I need to create an xml file and write and read from it with the following structure

I have tried creating it using the

<GeneratedSPs>
<StoredProcedure Name="Customer_ReadAll" ReturnType="DataTable"/>
<StoredProcedure Name="Customer_Read" ReturnType="DataTable"/>
<"/GeneratedSPs>

or any other structure that i could have "Name and return type"


Private Sub WriteXml()

Dim xtw As XmlTextWriter
Dim xmlFileName As String = String.Empty
Dim fsOut As IO.FileStream
Dim path As String = "C:\TestFolder"
' Try
'//Open the file and read it's contents
'//if it exists filemode.create will overwrite it
fsOut = New IO.FileStream(path, IO.FileMode.Create)
'// Create the output XML file.
xtw = New XmlTextWriter(fsOut, System.Text.Encoding.UTF8)

With xtw

.Indentation = 4
'// Start the document.
'// Writes the XML declaration with the version "1.0"
'//and the standalone attribute.
.WriteStartDocument(True)

'//Add a comment
.WriteComment("Xml file of the function calls to generate.")

'//add root element
.WriteStartElement("GeneratedSPS")

Dim lvwItem As ListViewItem = Nothing

' For Each lvwItem In DualSps.RightListView.Items
'//add Children to the root element
.WriteStartElement("StoredProcedure")
.WriteAttributeString("Name", "Customer_ReadAll")
.WriteAttributeString("ReturnType", "dataset")
.WriteEndElement()
' Next
'//end root element
.WriteEndElement()
End With

' Catch ex As Exception
'Finally
' xtextHelp.FinishXmlTextDocument(xtw)
'fsOut.Close()
' End Try


End Sub
private sub

It looks like some permission.Your help will be very much appreciated

thanks again
vbjunkie

vbjunkie at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 6

Hi,

My first observance is that you seem to write directly to a folder object. I think you'll have to specify a valid filename for that routine to work.

Dim path As String = "C:\TestFolder\test.xml"

cheers,

Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 7
Hi,
Quickly I have noticed that by putting also the name of the file it does create the xml file.

HOw silly of me.

Thanks for spotting.

vbjunkie

vbjunkie at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified