<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Getting Started</title><link>http://forums.asp.net/15.aspx</link><description>The perfect forum for ASP.NET novices. No question too simple! &lt;A href="http://aspadvice.com/SignUp/list.aspx?l=21&amp;amp;c=17" target=_blank&gt;Email List&lt;/A&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Format filesize in kB or MB</title><link>http://forums.asp.net/thread/2524915.aspx</link><pubDate>Wed, 30 Jul 2008 12:52:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2524915</guid><dc:creator>alperdotnet</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2524915.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=2524915</wfw:commentRss><description>&lt;p&gt;I use to same code.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Public Function BytesToMegabytes(Bytes As Double) As Double&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;#39;This function gives an estimate to two decimal&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;#39;places.&amp;nbsp; For a more precise answer, format to&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;#39;more decimal places or just return dblAns&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; Dim dblAns As Double&lt;br /&gt;&amp;nbsp; dblAns = (Bytes / 1024) / 1024&lt;br /&gt;&amp;nbsp; BytesToMegabytes = Format(dblAns, &amp;quot;###,###,##0.00&amp;quot;)&lt;br /&gt;&amp;nbsp; &lt;br /&gt;End Function&lt;/p&gt;</description></item><item><title>Re: Format filesize in kB or MB</title><link>http://forums.asp.net/thread/304317.aspx</link><pubDate>Fri, 08 Aug 2003 20:21:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:304317</guid><dc:creator>bdesmet</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/304317.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=304317</wfw:commentRss><description>You can use this piece of C# code to do this:
&lt;br /&gt;
&lt;pre&gt;using System;
&lt;br /&gt;
class Test
&lt;br /&gt;
{
&lt;br /&gt;
	public static void Main(string[]args)
&lt;br /&gt;
	{
&lt;br /&gt;
		Console.WriteLine(GetSize(int.Parse(args[0])));
&lt;br /&gt;
	}
&lt;br /&gt;

&lt;br /&gt;
	public static string GetSize(long size)
&lt;br /&gt;
	{
&lt;br /&gt;
		double s = size;
&lt;br /&gt;

&lt;br /&gt;
		string[] format = new string[] {&amp;quot;{0} bytes&amp;quot;, &amp;quot;{0} MB&amp;quot;, &amp;quot;{0} GB&amp;quot;, &amp;quot;{0} TB&amp;quot;, &amp;quot;{0} PB&amp;quot;, &amp;quot;{0} EB&amp;quot;};
&lt;br /&gt;

&lt;br /&gt;
		int i = 0;
&lt;br /&gt;
		while (i &amp;lt; format.Length &amp;amp;&amp;amp; s &amp;gt;= 1024) {
&lt;br /&gt;
			s = (int) (100 * s / 1024) / 100.0;
&lt;br /&gt;
			i++;
&lt;br /&gt;
		}
&lt;br /&gt;
	
&lt;br /&gt;
		return string.Format(format[i],s);
&lt;br /&gt;
	}
&lt;br /&gt;
}&lt;/pre&gt;</description></item><item><title>Re: Format filesize in kB or MB</title><link>http://forums.asp.net/thread/304239.aspx</link><pubDate>Fri, 08 Aug 2003 19:14:08 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:304239</guid><dc:creator>bleroy</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/304239.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=304239</wfw:commentRss><description>Hi,
&lt;br /&gt;

&lt;br /&gt;
A kB is 1024 bytes, and a MB is 1024 kB. Do the math...
&lt;br /&gt;

&lt;br /&gt;
Hope this helps.</description></item><item><title>Re: Format filesize in kB or MB</title><link>http://forums.asp.net/thread/304234.aspx</link><pubDate>Fri, 08 Aug 2003 19:09:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:304234</guid><dc:creator>bsmith80</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/304234.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=304234</wfw:commentRss><description>There isn't anything built in that I know of but it's really easy to accomplish this.  I normally use something like this:&lt;pre&gt;
&lt;br /&gt;
if (fsize &amp;lt; 1024)
&lt;br /&gt;
// code to format fsize as bytes
&lt;br /&gt;
else if ((fsize &amp;gt; 1024) &amp;amp;&amp;amp; (fsize &amp;lt; 1048576))
&lt;br /&gt;
// code to format fsize as KB
&lt;br /&gt;
else if (fsize &amp;gt; 1048576)
&lt;br /&gt;
// code to format fsize as MB&lt;/pre&gt;
&lt;br /&gt;

&lt;br /&gt;
If there is something built in to do this, I would like to know about it too.</description></item><item><title>Format filesize in kB or MB</title><link>http://forums.asp.net/thread/304193.aspx</link><pubDate>Fri, 08 Aug 2003 18:41:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:304193</guid><dc:creator>ShadowDanser</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/304193.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=15&amp;PostID=304193</wfw:commentRss><description>Hello,
&lt;br /&gt;

&lt;br /&gt;
When I have read a file with x.xxx.xxx.xxx bytes it is sometimes handy to show it in an diverent format than bytes.
&lt;br /&gt;

&lt;br /&gt;
Is there a handy way to do this?
&lt;br /&gt;
Or is there a function for it?
&lt;br /&gt;

&lt;br /&gt;
When it is a big file I want to see a MB size and when it is a lower file size then I want to see a kB size for example.
&lt;br /&gt;

&lt;br /&gt;
Thanks!
&lt;br /&gt;

&lt;br /&gt;</description></item></channel></rss>