2

I have a text file in the following path :

\\129.253.145.235\Hostsw\Host\SW\DIABLO3S\CONFIGSW\AMBIENT6\MATRIX\VALIDCCC.TXT

I am reading the textfile as follows:

     Dim file As StreamWriter = New StreamWriter(filepath, True)

Appending new lines as Follows :

   file.WriteLine(sb)
   file.Close()

I am getting error message :

Access to the path '\129.253.145.235\Hostsw\Host\SW\DIABLO3S\CONFIGSW\AMBIENT6\MATRIX\VALIDCCC.TXT' is denied.

If textfile is exists then only i need to append new lines into textfile.

Sathish
  • 4,419
  • 4
  • 30
  • 59
Kapil
  • 1,823
  • 6
  • 25
  • 47
  • What is the security profile of this file? Do `Auth` users have write access to it? –  Mar 19 '14 at 03:58

1 Answers1

0

Damian Drygiel Has mentioned here

Your asp.net account {MACHINE}\ASPNET does not have write access to that location. That is the reason why its failing.

Consider granting access rights to the resource to the ASP.NET request identity.

Right click on downloading folder Properties > Security Tab > Edit > Add > locations > choose your local machine > click OK > Type ASPNET below "Enter the object name to select" > Click Check Names Check the boxes for the desired access (Full Control). If it will not wok for you do the same with Network Service

Now this should show your local {MACHINENAME}\ASPNET account, then you set the write permission to this account.

Otherwise if the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.


Or just use dedicated location for storing files in ASP.NET which is App_Data. To create it right click on your ASP.NET Project (in Visual Studio) Add > Add ASP.NET Folder > App_Data. Then you'll be able to save data to this location:

OR:

We reclaimed ownership of the folders. You can do this in the security tab of the ASP.NET Temporary files directory.

  • Right click and select "Properties"
  • Select the "Security" tab
  • Click on the "Advanced" button
  • Select the "Owner" tab
  • Select the owner (MACHINENAME\Administrators), check the "Replace owner on subcontainers and objects" and click OK
Community
  • 1
  • 1
Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115