Problem creating a folder using system.io

Discussion in 'ASP.NET / ASP.NET Core' started by meedar, Jun 28, 2009.

  1. Hello to all!
    Please give assitance. I am trying to create a folder using the system.io
    I am receiving access denied and checked the control panel and the anonymous user(ASPnet worker) has a read-write permission.

    Here's the script for testing that I created.

    Imports System.IO
    Imports System.DirectoryServices
    Partial Class test
    Inherits System.Web.UI.Page


    Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load

    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim createdir As String = "testdirect"
    If Directory.Exists(createdir.Trim) Then
    Me.Response.Write("<script>alert('Directory Exist.')</script>")
    Else
    Directory.CreateDirectory(createdir.Trim) ' ACCESS DENIED HERE!!!
    End If
    End Sub
    End Class

    I want to create a folder named "testdirect". Do I have to configure the webconfig? I am new in ASPNET.... Please Help!!!

    Kind Regards,

    Jake
     
  2. Thanks anyway! I already solved the problem my self. I just add a "Server.MapPath" the script it's ok. I just want to share this to others. See script below..

    Imports System.IO
    Imports System.DirectoryServices
    Partial Class test
    Inherits System.Web.UI.Page



    Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim createdir As String = "testdirect"

    If Directory.Exists(Server.MapPath(createdir.Trim)) Then
    Me.Response.Write("<script>alert('Directory Exist.')</script>")
    Else
    Directory.CreateDirectory(Server.MapPath(createdir))


    End If

    End Sub


    End Class
     
  3. Good job ;-)
     

Share This Page