IntroductionThis Article explain some useful functinality in System.IO.FileInfo class. and also few useful method for the file size customization. ImplementationThe Windows system could store additional information like provide additional inforamtion with fileInfo class and more and more. and base dll System.dll. Then we need design a simple GUI like followings. 
It's simple user interface for this demo,and also source code can be download bellow link Using Code {codecitation class="brush: csharp; gutter: true;" width="650px"} #region [ string GetSegment (string ParentPath)] /// /// Get File segment and size. /// /// /// public string GetSegment (string ParentPath) {
string Container = string.Empty; int segmentCount = 0; long lastsegmentSize = 0;
long fileSizeinBytes = 0; try { if (!string.IsNullOrEmpty (ParentPath)) { if (File.Exists (ParentPath)) { FileInfo objRecordedFileInfo = new FileInfo (ParentPath); fileSizeinBytes = objRecordedFileInfo.Length;
if (fileSizeinBytes > Convert.ToInt64 (bufferSize)) { segmentCount = Convert.ToInt32 (fileSizeinBytes / bufferSize); lastsegmentSize = Convert.ToInt64 (fileSizeinBytes % bufferSize); Container = segmentCount + "|" + lastsegmentSize + "|" + fileSizeinBytes; } else { Container = segmentCount + "|" + fileSizeinBytes + fileSizeinBytes; } } else { Container = segmentCount + "|" + lastsegmentSize + fileSizeinBytes; } } } #region [ Exception Handling in Presetation Layer ]
#region [General Exception ] catch (Exception ex) { throw ex; } #endregion
#endregion
return Container; } #endregion
{/codecitation} and also you can customize buffer size. and another simple snippt for File basic attribue provide by the Microsoft class library,but here demo 
and snippts {codecitation class="brush: csharp; gutter: true;" width="650px"} private void GetFileAttibutes (string Filename) { FileInfo objFileInfo=new FileInfo(Filename); FileAttributes objFileAttributes = objFileInfo.Attributes; switch (objFileAttributes) { case FileAttributes.Archive: chkArchive.Checked = true; break; case FileAttributes.Compressed: chkCompressed.Checked = true; break; case FileAttributes.Device: chkDevice.Checked = true; break; case FileAttributes.Directory: chkDirectory.Checked = true; break; case FileAttributes.Encrypted: chkEncrypted.Checked = true; break; case FileAttributes.Hidden: chkHidden.Checked = true; break; case FileAttributes.Normal: chkNormal.Checked = true; break; case FileAttributes.NotContentIndexed: chkNotContentIndexed.Checked = true; break; case FileAttributes.Offline: chkOffline.Checked = true; break; case FileAttributes.ReadOnly: chkReadOnly.Checked = true; break; case FileAttributes.System: chkSystem.Checked = true; break; case FileAttributes.Temporary: chkTemporary.Checked = true; break;
} }
{/codecitation} Conclusion This is article explain about how to get a fille information using .NET classes. Thank you RRaveen |