Posts

Showing posts with the label etc

Finding file size in bytes on serverside using c#

Hi, This requirement will come mainly while doing I/O operations (in my opinion it is obviously one of tedious taks carried by server). Here am showing you the snippet of code to find out the number of bytes of a file. here am using this code to validate the size of the file on server side. Which is a common requirement while doing file uploads. Here is the snippet. private static long GetFileSizeOnDisk(string filelocation) { FileInfo info = new FileInfo(file); uint dummy, sectorsPerCluster, bytesPerSector; int result = GetDiskFreeSpaceW(info.Directory.Root.FullName, out sectorsPerCluster, out bytesPerSector, out dummy, out dummy); if (result == 0) throw new Win32Exception(); uint clusterSize = sectorsPerCluster * bytesPerSector; uint hosize; uint losize = GetCompressedFileSizeW(file, out hosize); long size; size = (long)hosize Thanks & Regards, Pavan N

Part– I : Coding standards

Coding practise defines the developer awareness of writing a good code. but not his technical expertise..... I mean a little :) As of my experience with different projects across the domains and technologies & tools I got  a chance to work on enhancements, bug fixings, code reviewing, code development from the scratch level, enhancing my own code which was written years back by myself  :) , reading and preparing documentation on reviewing the code base from the client..... and many more. I got realised few points which i would like to blog.