Check the given Path is of a File or a Directory

Below sample code will help you How to check the given path is of a File or a Directory?

Add below namespace on your page,
using System.IO;

Solution :
string path = @"C:\Test.xml";
if (File.Exists(path))
{
      Response.Write(path + " is a File.");
}
else if (Directory.Exists(path))
{
      Response.Write(path + " is a Directory.");
}

Get Computer Name

How to Get/Find your Computer/machine Name is easy using simple line of code,

Response.Write("My Computer Name: " + System.Environment.MachineName);

Extract Domain Name and User Name

If you want to extract Domain name and User name you can use below code,

Dim strDomain As String

'Extract domain name and username
strDomain = System.Security.Principal.WindowsIdentity.GetCurrent.Name

MsgBox(strDomain)


'Extract domain name from full login
strDomain = Mid(strDomain, 1, InStr(strDomain, "\") - 1)

MsgBox(strDomain)