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.");
}
The .NET Framework allows developers to use the same set of skills to rapidly buid great applications for the web, windows, services and more.
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);
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)
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)
Subscribe to:
Posts (Atom)