Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a directory 1

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
I am trying to create a directory after my code checks to see if it exist or not, but it is only creating a file. my code is below..

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If blnstandard.Checked = False Then
Dim strsubdomain As String
Dim Result As Boolean = System.IO.Directory.Exists("\" & txtsubdomain.Text)
If Result = True Then
lblstatuswindow.Text = "Sub-Domain Already Exist. Please choose a different sub-domain name."
Else
strsubdomain = "\" & txtsubdomain.Text
System.IO.Directory.CreateDirectory(strsubdomain)
lblstatuswindow.Text = "created " & txtsubdomain.Text & " Sub-Domain"
End If


End If
 
This directory will be created on the Net or in a local hard drive ?
 
Code:
        Dim strsubdomain, myText
        myText = "Mydir"
        strsubdomain = "\" & myText
        System.IO.Directory.CreateDirectory(strsubdomain)
that code created "C:\Mydir".

Check your defaults and the content of "txtsubdomain.Text".

 
By the way, what's the content of "strsubdomain"?
Also, can you break right after " System.IO.Directory.CreateDirectory(strsubdomain)", and see what happened?
 
dimandja,

the code you posted still only creates a file. Does not create a sub directory is is still createing a file..
 
Dim path As String = "c:\MyDir"
Dim di As DirectoryInfo = Directory.CreateDirectory(path)

Eric De Decker
Visit The Belgium "Visual Basic Group" at
 
edderic,

This code you posted also only creates a file not a directory. I am trying to do this through the web, and when the user designated the directory name it will created it on the server.
 
When the path start with "\" means the root.

The folder will be created unless its name (textbox's Text) contains invalid chars: *?"<>| . If it contains / or \ there will be no exception but a subfolder will be created.

If the folder's last char is dot "." and you write: System.IO.Directory.CreateDirectory("\blah.") simply it will NOT be created. If manually try to do this; the dot will be omitted and the dir will be created.

This code cannot create a file.
If you wanna create a folder in the internet by a windows application; say that because you mentios "sub-domain", things are a little different.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top