ASP.NET (35) SQL (25) JAVASCRIPT (24) HTML (14) STYLE SHEET (6) ASP (4) SCRIPT (1)

Search me out HERE!!

Get list of all files from directory in C#, ASP.Net

Using below code you can list out all files or files with respective extension for given directory in C#:

DirectoryInfo di = new DirectoryInfo("c:/demos");
FileInfo[] rgAllFiles = di.GetFiles();  //Get list of all files.
FileInfo[] rgFiles = di.GetFiles("*.aspx");  //Get list of only .aspx files.

// You can use each file using below iteration
foreach(FileInfo fi in rgAllFiles)
{
  Response.Write(fi.Name);       

Get file name from path using Javascript

Using below javascript function you can get file name from path:

function GetFileName()
{
   var fullPath = 'http://kapilgbaheti.blogspot.in/2012/08/get-file-name-from-path.html';
   var filename = fullPath.replace(/^.*[\\\/]/, '');
   alert(filename);
}

You output will be : get-file-name-from-path.html

Get Screen Width and Screen Height using Javascript

Below is code to get Screen Width and Height using Javascript;

function getScreenInfo()
{
    var w = screen.width;
    var h = screen.height;
    alert("Screen Width :" + w + ", Screen Height:" + h);
}

Note: You cannot get screen width/height in ASP.net server side code, you need to manage it using Javascript.