Asp.net, vb.net, C#.net Resources

Welcome to Asp.net, vb.net, C#.net Resources Sign in | Join | Help
in Search

How to detect if the string indicating a file-system resource is a file or directory?

Last post 08-30-2006, 12:34 AM by Webdeveloper. 1 replies.
Sort Posts: Previous Next
  •  08-21-2006, 6:52 AM 389

    How to detect if the string indicating a file-system resource is a file or directory?

    How to detect if the string indicating a file-system resource is a file or directory?
  •  08-30-2006, 12:34 AM 956 in reply to 389

    Re: How to detect if the string indicating a file-system resource is a file or directory?

    VB.NET


    Dim path As String = Server.MapPath("webform1.aspx")
    ' Put user code to initialize the page here
    If(File.GetAttributes(path) And FileAttributes.Directory) = FileAttributes.Directory Then
         Response.Write("Its a directory")
    Else
         Response.Write("Its a file")
    End If


    C#


    string path =Server.MapPath ("webform1.aspx");
    if ((File.GetAttributes(path) & FileAttributes.Directory) ==FileAttributes.Directory)
    {
         Response.Write ("Its a directory");
    }
    else
    {
         Response.Write ("Its a file");
    }

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems