Disable Browser Back Button Using Javascript:

Just put this javascript on the html section to disable browser's back button.(avoid user going to previous page by clicking on back button of browser).

The scripts work all major browsers like IE,FF.Chrome

<script language="javascript" type="text/javascript">

        noBack2();

        function noBack2(){window.history.forward();}
        window.onload=noBack2;
        window.onpageshow=function(evt){if(evt.persisted)noBack2();}
        window.onunload=function(){void(0);}

</script>


Read more ...

     Calculate the Size of a Folder/Directory using .NET 4.0   
   
     .NET 4.0 introduces 7 New methods to Enumerate Directory and Files in .NET 4.0.
    All these methods return Enumerable Collections (IEnumerable<T>), which perform better   than  arrays.
    We will be using the DirectoryInfo.EnumerateDirectories and DirectoryInfo.
    EnumerateFiles in this sample which returns an enumerable
    collection of Directory and File information respectively.
   
    Here's how to calculate the size of a folder or directory using .NET 4.0 and LINQ.
    The code also calculates the size of all sub-directories.
   
    Calculate the Size of a Folder/Directory using C#
   
    using System;
    using System.Linq;
    using System.IO;
   
    namespace DirectoryInfo
    {
      class Program
      {
        static void Main(string[] args)
        {
          DirectoryInfo dInfo = new DirectoryInfo(@"Your folder path here");
          // set bool parameter to false if you
          // do not want to include subdirectories.
          long sizeOfDir = DirectorySize(dInfo, true);
   
          Console.WriteLine("Directory size in Bytes : " +
          "{0:N0} Bytes", sizeOfDir);
          Console.WriteLine("Directory size in KB : " +
          "{0:N2} KB", ((double)sizeOfDir) / 1024);
          Console.WriteLine("Directory size in MB : " +
          "{0:N2} MB", ((double)sizeOfDir) / (1024 * 1024));
   
          Console.ReadLine();
        }
   
        static long DirectorySize(DirectoryInfo dInfo, bool includeSubDir)
        {
           // Enumerate all the files
           long totalSize = dInfo.EnumerateFiles()
                        .Sum(file => file.Length);
   
           // If Subdirectories are to be included
           if (includeSubDir)
           {
              // Enumerate all sub-directories
              totalSize += dInfo.EnumerateDirectories()
                       .Sum(dir => DirectorySize(dir, true));
           }
           return totalSize;
        }
      }
    }
Read more ...

Somebody got error message like
"The web services enumeration components are not available.  You need to reinstall Visual Studio to add web references to your application".
while try to add web references Sounds like the installation is somehow corrupted.

For quick solutions try the following

1) Run->
"devenv /resetskippkgs" , (without quotes)

2)
when having 2 VS installed (like VS2008 and VS2005) on same machine it is better to parse command with the full path name:
"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe" /resetskippkg




Read more ...

Related Posts Plugin for WordPress, Blogger...