Skip to main content

Posts

Set timer using java script

//Java Script <script language="javascript" type="text/javascript"> window.setTimeout("HideDiv()", 15000); //Hide Div after 15 seconds function HideDiv() { document.getElementById('Layer2').style.display = "none"; } </script> // HTML <div id="Layer2" > Sample Text Here </div>

How blink a text on IE Browser.

//Java Script <script type="text/javascript"> function doBlink() { var blink = document.all.tags("BLINK") for (var i = 0; i < blink.length; i++) blink .style.visibility = blink .style.visibility == "" ? "hidden" : "" } function startBlink() { if (document.all) setInterval("doBlink()", 500) } window.onload = startBlink; </script> //CSS <style type="text/css"> blink { -webkit-animation-name: blink; -webkit-animation-iteration-count: infinite; -webkit-animation-timing-function: cubic-bezier(1.0,0,0,1.0); -webkit-animation-duration: 1s; } </style> //HTML <span style="color: Red; font-size: 11px; font-family: Times New Roman;"> <blink>New!</b...

Delete All Files (*.*) [C#]

This examples shows how to delete all files (*.*) from a folder in C#. First, you need to get the list of file names from the specified directory (using static method Directory.Get­Files . Then delete all files from the list. Delete all files [C#] using System.IO; string [] filePaths = Directory .GetFiles( @"c:\MyDir\" ); foreach ( string filePath in filePaths) File .Delete(filePath); Delete all files (one-row example) To delete all files using one code line, you can use Array.ForEach with combination of anonymous method. [C#] Array .ForEach( Directory .GetFiles( @"c:\MyDir\" ), delegate ( string path) { File .Delete(path); });

FileStream Read File [C#]

This example shows how to safely read file using FileStream in C# . To be sure the whole file is correctly read, you should call FileStream.Read method in a loop, even if in the most cases the whole file is read in a single call of FileStream.Read method. Read file using FileStream First create FileStream to open a file for reading. Then call FileStream.Read in a loop until the whole file is read. Finally close the stream. [C#] using System.IO; public static byte [] ReadFile ( string filePath) { byte [] buffer; FileStream fileStream = new FileStream (filePath, FileMode .Open, FileAccess .Read); try { int length = ( int )fileStream.Length; // get file length buffer = new byte [length]; // create buffer int count; // actual number of bytes read int sum = 0; // total number of bytes read // read until Read method returns 0 (end of the stream has been reached) while...

Load Text from File to String [C#]

This example shows how to load text file to string variable. StreamReader To load text from file to string you can use StreamReader. Re­adToEnd method. First create new instance of StreamReader . As a parameter in constructor you can pass string with file path or Stream instance. Default encoding is UTF-8. [C#] using System.IO; StreamReader streamReader = new StreamReader (filePath); string text = streamReader. ReadToEnd() ; streamReader.Close();