1 #region GetFileSizeInBytes()// Funciton to get the File Size in Bytes ...
2
3 private string GetFileSizeInBytes() // Function to return the file size in Bytes
4 {
5 string FlSize = "0 Bytes";
6
7
8 if (fuDownload.HasFile)
9 {
10 string flActualByte = fuDownload.FileBytes.Length.ToString();
11 if (flActualByte.Length == 3)
12 {
13 FlSize = flActualByte + "bytes";
14 }
15 else if (flActualByte.Length == 4)
16 {
17 flActualByte = flActualByte.Substring(0, 2);
18 flActualByte = flActualByte.Insert(1, ".");
19
20 FlSize = flActualByte + " kB";
21 }
22 else if (flActualByte.Length == 5)
23 {
24 flActualByte = flActualByte.Substring(0, 3);
25 flActualByte = flActualByte.Insert(2, ".");
26
27 FlSize = flActualByte + " kB";
28 }
29 else if (flActualByte.Length == 6)
30 {
31 flActualByte = flActualByte.Substring(0, 4);
32 flActualByte = flActualByte.Insert(3, ".");
33
34 FlSize = flActualByte + " kB";
35 }
36 else if (flActualByte.Length == 7)
37 {
38 flActualByte = flActualByte.Substring(0, 2);
39 flActualByte = flActualByte.Insert(1, ".");
40
41 FlSize = flActualByte + " MB";
42 }
43 else if (flActualByte.Length == 8)
44 {
45 flActualByte = flActualByte.Substring(0, 3);
46 flActualByte = flActualByte.Insert(2, ".");
47
48 FlSize = flActualByte + " MB";
49 }
50 else if (flActualByte.Length == 9)
51 {
52 flActualByte = flActualByte.Substring(0, 4);
53 flActualByte = flActualByte.Insert(3, ".");
54
55 FlSize = flActualByte + " MB";
56 }
57 else if (flActualByte.Length == 10)
58 {
59 flActualByte = flActualByte.Substring(0, 2);
60 flActualByte = flActualByte.Insert(1, ".");
61
62 FlSize = flActualByte + " GB";
63 }
64
65 }
66
67 return FlSize;
68 }
69 #endregion