Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-11-2009
Member
 
Join Date: Jul 2009
Posts: 36
How to create directory in ASP.net

Hello friends,

I am facing some issue with my project when i am trying to create a directory by using Directory class, it's not allowing me to find do so and at the same time i am unable to find a shared function which allows me to create a directory, I have tried to lot over internet but was not able to get proper solution. Can anyone tell me how to create directory in ASP.net ?
Reply With Quote
  #2  
Old 11-11-2009
Member
 
Join Date: Nov 2005
Posts: 403
Create directory in ASP.net

If you want to create a directory in ASP.net then simply write directory to the disk, before that you need to import System.IO namespace, this contains the CreateDirectory() method that we will be used to create your directory and if you are using Server Intellect then insert the following code in btnSubmit_Click() event.

Code:
Protected Sub btnSubmit_Click(ByVal sender1 As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Try
Directory.CreateDirectory(MapPath(".") & "\" & txt_Dir.Text)
Catch ex1 As Exception
lblStatus.Text = ex1.Message
End Try
End Sub
Reply With Quote
  #3  
Old 11-11-2009
Members
 
Join Date: Apr 2009
Posts: 47
How to create directory in ASP.net

I also want to create a folder in asp.net with by using Create Directory Function, i have tried a lot but i am not able to create one for me, does anyone provide me any code where i can create directory in ASP.net using Create Directory Function. Thanks in Advance.
Reply With Quote
  #4  
Old 11-11-2009
Member
 
Join Date: Jan 2009
Posts: 150
Re: How to create directory in ASP.net

It's very simple if you want to use Create Directory Function in asp.net then try to use the below code which will create a directory for you. I am sure this will work for you and if a directory exist then you will get a message as Directory Already Exist.

Code:
Public Function CreateDirectory(ByVal Directory_Name As String) As String
        If Directory.Exists(Server.MapPath(Directory_Name)) Then
            Return "Directory Already Exist"
        Else
            Try
                Directory.CreateDirectory(Server.MapPath(Directory_Name))
                Dim oMenu As New cMenu
            Catch ex As Exception
                Return "Failue" + ex.ToString
            End Try
        End If
        Return "Success"
    End Function
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to create directory in ASP.net"
Thread Thread Starter Forum Replies Last Post
Create Active Directory integrated zone in DNS Brruno Networking & Security 3 12-11-2010 06:17 AM
Should I create a virtual directory Lashawn Software Development 5 19-01-2010 09:28 PM
How to create a directory in c++ Gomeler Software Development 3 25-11-2009 11:14 AM
useradd: cannot create directory MobiNuX Operating Systems 2 30-07-2009 10:51 PM
How to create an alias for a directory in Unix Bull50 Operating Systems 3 02-05-2009 09:05 PM


All times are GMT +5.5. The time now is 07:28 PM.