Use System.IO namespace
VB.NET
Dim path As String = ''
try
’ Determine whether the directory exists.
If Directory.Exists(path) Then
Response.Write('That path exists already.')
Return
End If
’ Try to create the directory.
Dim di As DirectoryInfo = Directory.CreateDirectory(path)
Response.Write(('Directory create successfully at ' + Directory.GetCreationTime(path)))
catch ex as Exception
Response.Write (ex.Message )
end try
C#
string path = @'c:\MyDir';
try
{
// Determine whether the directory exists.
if (Directory.Exists(path))
{
Response.Write ('That path exists already.');
return;
}
// Try to create the directory.
DirectoryInfo di = Directory.CreateDirectory(path);
Response.Write('Directory create successfully at ' + Directory.GetCreationTime(path));
}
catch(Exception ex)
{
Response.Write (ex.Message );
}
Share with