qr code scanner for java mobile Calculating Disk Usage in .NET

Printing ECC200 in .NET Calculating Disk Usage

627 Calculating Disk Usage
Read Data Matrix In Visual Studio .NET
Using Barcode Control SDK for .NET framework Control to generate, create, read, scan barcode image in .NET applications.
Print DataMatrix In .NET
Using Barcode drawer for .NET Control to generate, create Data Matrix image in .NET applications.
Problem
Data Matrix ECC200 Scanner In .NET
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET framework applications.
Bar Code Printer In .NET
Using Barcode generator for VS .NET Control to generate, create bar code image in Visual Studio .NET applications.
You want to calculate the total disk space used by a disk partition or directory
Scanning Barcode In Visual Studio .NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
Data Matrix Maker In Visual C#
Using Barcode generator for .NET Control to generate, create Data Matrix 2d barcode image in .NET applications.
Solution
Printing DataMatrix In .NET Framework
Using Barcode creator for ASP.NET Control to generate, create Data Matrix image in ASP.NET applications.
Drawing Data Matrix In Visual Basic .NET
Using Barcode creator for .NET Control to generate, create Data Matrix 2d barcode image in Visual Studio .NET applications.
Use PHP s disk_free_space() and disk_total_space() functions to calculate the total disk usage for a partition:
Paint UPC-A Supplement 5 In VS .NET
Using Barcode creator for VS .NET Control to generate, create UPC Code image in Visual Studio .NET applications.
EAN 128 Drawer In .NET
Using Barcode maker for VS .NET Control to generate, create EAN / UCC - 13 image in .NET applications.
< php // define partition // for example, "C:" for Windows // or "/" for UNIX $dir = "c:"; // get free space in MB $free = round(disk_free_space($dir)/1048576);
EAN / UCC - 13 Generation In VS .NET
Using Barcode generator for .NET framework Control to generate, create European Article Number 13 image in Visual Studio .NET applications.
Generating MSI Plessey In VS .NET
Using Barcode generation for VS .NET Control to generate, create MSI Plessey image in VS .NET applications.
PHP Programming Solutions
Printing Code 3/9 In None
Using Barcode creation for Online Control to generate, create Code39 image in Online applications.
Matrix 2D Barcode Drawer In .NET
Using Barcode generator for ASP.NET Control to generate, create 2D Barcode image in ASP.NET applications.
// get total available space in MB $total = round(disk_total_space($dir)/1048576); // calculate used space in MB $used = $total - $free; echo "$used MB used"; >
Reading UPC Symbol In .NET
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
Code 128B Generation In Java
Using Barcode generator for Java Control to generate, create Code 128 Code Set A image in Java applications.
Write a recursive function to calculate the total disk space consumed by a particular directory:
EAN / UCC - 13 Generation In Objective-C
Using Barcode encoder for iPhone Control to generate, create EAN-13 Supplement 5 image in iPhone applications.
Printing Linear 1D Barcode In Visual C#
Using Barcode encoder for VS .NET Control to generate, create Linear 1D Barcode image in Visual Studio .NET applications.
< php // function to recursively process // a directory and all its subdirectories function calcDirUsage($dir) { // check if argument is a valid directory if (!is_dir($dir)) { die("Argument '$dir' is not a directory!"); } // declare variable to hold running total global $byteCount; // open directory handle $dh = opendir($dir) or die ("Cannot open directory '$dir'!"); // iterate over files in directory while (($file = readdir($dh)) !== false) { // filter out "" and "" if ($file != "" && $file != "") { if (is_dir("$dir/$file")) { // if this is a subdirectory // recursively process it calcDirUsage("$dir/$file"); } else { // if this is a file // add its size to the running total $byteCount += filesize("$dir/$file"); } } } // return the final list to the caller return $byteCount; }
Scan Bar Code In Visual Basic .NET
Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in VS .NET applications.
Encoding Bar Code In Java
Using Barcode printer for Java Control to generate, create barcode image in Java applications.
6: Working with Files and Directories
// calculate disk usage for directory in MB $bytes = calcDirUsage("c:/windows"); $used = round($bytes/1048576); echo "$used MB used"; >
Comments
PHP s disk_total_space() and disk_free_space() functions return the maximum and available disk space for a particular drive or partition respectively, in bytes Subtracting the latter from the former returns the number of bytes currently in use on the partition Obtaining the disk space used by a specific directory and its subdirectories is somewhat more complex The task here involves adding the sizes of all the files in that directory and its subdirectories to arrive at a total count of bytes used The simplest way to accomplish this is with a recursive function such as the one outlined in the previous listing, where file sizes are calculated and added to a running total Directories are deal with recursively, in a manner reminiscent of the technique outlined in the listing in 611: Recursively Processing Directories The final sum will be the total bytes consumed by the directory and all its contents (including subdirectories)
To convert byte values to megabyte or gigabyte values for display, divide by 1048576 or 1073741824 respectively
628 Creating Temporary Files
Problem
You want to create a temporary file with a unique name, perhaps as a flag or semaphore for other processes
Solution
Use PHP s tempnam() function:
< php // create temporary file with prefix "tmp" $filename = tempnam("/tmp", "tmp"); echo "Temporary file [$filename] successfully created"; >
PHP Programming Solutions
Comments
PHP s tempnam() function accepts two arguments, a directory name and a file prefix, and attempts to create a file using the prefix and a randomly generated identifier in the specified directory If the file is successfully created, the function returns the complete path and name to it this can then be used by other file functions to write data to it This listing offers an easy way to quickly create a file for temporary use, perhaps as a signal to other processes Note, however, that the file created by tempnam() must be manually deleted with unlink() once it s no longer required
PHP s tmpfile() function creates a unique, temporary file that exists only for the duration of the script Read more about this function at http://wwwphpnet/tmpfile
629 Finding the System Temporary Directory
Problem
You want to retrieve the path to the system s temporary directory
Solution
Use PHP s tempnam() function to create a temporary file, and then obtain the path to it:
< php // create a temporary file and get its name // result: "Temporary directory is /tmp" $tmpfile = tempnam("/this/directory/does/not/exist", "tmp"); unlink ($tmpfile); echo "Temporary directory is " dirname($tmpfile); >
Copyright © OnBarcode.com . All rights reserved.