Posts Tagged ‘C#’

Filesize convertion in c#

Just for sharing, I found this small code from this site and this is the easiest way for converting bytes (because I’m a Math guru who repeated College Algebra by 5 times that is why I picked this code rather dividing large numbers to 1024 by 1024 and so on…).So let Microsoft do the Math Okay! .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
        private string ToFileSize(long source)
        {
            const int byteConversion = 1024;
            double bytes = Convert.ToDouble(source);
 
            if (bytes >= Math.Pow(byteConversion, 4)) //TB Range
            {
                return string.Concat(Math.Round(bytes / Math.Pow(byteConversion, 4), 2), " TB");
            }
            if (bytes >= Math.Pow(byteConversion, 3)) //GB Range
            {
                return string.Concat(Math.Round(bytes / Math.Pow(byteConversion, 3), 2), " GB");
            }
            else if (bytes >= Math.Pow(byteConversion, 2)) //MB Range
            {
                return string.Concat(Math.Round(bytes / Math.Pow(byteConversion, 2), 2), " MB");
            }
            else if (bytes >= byteConversion) //KB Range
            {
                return string.Concat(Math.Round(bytes / byteConversion, 2), " KB");
            }
            else //Bytes
            {
                return string.Concat(bytes, " Bytes");
            }
        }

Another useful diagram I found (sorry but i lost the source of this picture, an apology to the author)

kilobyte

  • Share/Bookmark

A brand new start

Yesterday evening just minutes before the start of my daily routine work (of sleeping..just kidding!) I got a call from someone that I am waiting and praying for the past couple of days that maybe a start of my new better life and a career that Im dreaming of…

Goodluck to me.

PS: A million thanks to you Mr. Menno!

  • Share/Bookmark

New Site

The New (Beta from now) Microsoft Windows Server 208 R2, IIS 7.5 and the .Net Framework 4.0!

I decided that my next main site will run on these platforms to ensure that updates to new techs and be able to learn this ahead of time.

ASP.Net 4.0 Logo

The ASP.Net 4.0 Logo (unofficial)

My new website Response Header

My new website Response Header

Oh I missed already my WPF days when I was able to write parallel and multi-threaded programming . Whats good about the new framework,  this time you will never directly (as what I did in the 3.5) have to write with the  pool threads or worker threads. Whew!

Also, I am so intrigue with their new class- The LAZY class.

Anyway, too much to speak about them and if you like more info on this stuffs you can visit this links below…

Windows Server 2008 R2

IIS 7

ASP.Net / .Net Framework 4.0

  • Share/Bookmark
Return top

DISCLAIMER

Due to my superb English vocabulary, users are still encourage to use dictionary and thesaurus for your references :D
 

Switch to our mobile site