Click here to Skip to main content
Licence CPOL
First Posted 26 Feb 2007
Views 12,428
Bookmarked 8 times

This is basically focus files attributes with .net 2.0 IO base class library

By | 26 Feb 2007 | Article
THis atricle so some useful infomation any type of files and basic file attributes also
Screenshot - FM1.jpg

Download FileManagement_demo.zip - 11.1 KB

Download FileManagement_src.zip - 156 KB

Introduction

This Article explain some useful funcatinality in System.IO.FileInfo class. and also few useful method for the file size customization.

Background

The Windows system could store additional information like provide additional inforamtion with fileInfo class and more and more. and base dll System.dll.

It's simple user interface for this demo,and also source code can be download bellow link

Using Code

code snippts

<code>

#region [ string GetSegment (string ParentPath)]<br />/// <summary><br />/// Get File segment and size.<br />/// </summary><br />/// <param name="ParentPath"></param><br />/// <returns></returns><br />public string GetSegment (string ParentPath)<br />{<br /><br />string Container = string.Empty;<br />int segmentCount = 0;<br />long lastsegmentSize = 0;<br /><br />long fileSizeinBytes = 0;<br />try<br />{<br />if (!string.IsNullOrEmpty (ParentPath))<br />{<br />if (File.Exists (ParentPath))<br />{<br />FileInfo objRecordedFileInfo = new FileInfo (ParentPath);<br />fileSizeinBytes = objRecordedFileInfo.Length;<br /><br />if (fileSizeinBytes > Convert.ToInt64 (bufferSize))<br />{<br />segmentCount = Convert.ToInt32 (fileSizeinBytes / bufferSize);<br />lastsegmentSize = Convert.ToInt64 (fileSizeinBytes % bufferSize);<br />Container = segmentCount + "|" + lastsegmentSize + "|" + fileSizeinBytes;<br />}<br />else<br />{<br />Container = segmentCount + "|" + fileSizeinBytes + fileSizeinBytes;<br />}<br />}<br />else<br />{<br />Container = segmentCount + "|" + lastsegmentSize + fileSizeinBytes;<br />}<br />}<br />}<br />#region [ Exception Handling in Presetation Layer ]<br /><br />#region [General Exception ]<br />catch (Exception ex)<br />{<br />throw ex;<br />}<br />#endregion<br /><br />#endregion<br /><br />return Container;<br />}<br />#endregion 

</code>

and also you can customize buffer size.

and another simple snippt for File basic attribue provide by the Microsoft class library,but here demo

Screenshot - FM2.jpg

and snippts

<code>

private void GetFileAttibutes (string Filename)<br />{<br />FileInfo objFileInfo=new FileInfo(Filename);<br />FileAttributes objFileAttributes = objFileInfo.Attributes;<br />switch (objFileAttributes)<br />{<br />case FileAttributes.Archive:<br />chkArchive.Checked = true;<br />break;<br />case FileAttributes.Compressed:<br />chkCompressed.Checked = true;<br />break;<br />case FileAttributes.Device:<br />chkDevice.Checked = true;<br />break;<br />case FileAttributes.Directory:<br />chkDirectory.Checked = true;<br />break;<br />case FileAttributes.Encrypted:<br />chkEncrypted.Checked = true;<br />break;<br />case FileAttributes.Hidden:<br />chkHidden.Checked = true;<br />break;<br />case FileAttributes.Normal:<br />chkNormal.Checked = true;<br />break;<br />case FileAttributes.NotContentIndexed:<br />chkNotContentIndexed.Checked = true;<br />break;<br />case FileAttributes.Offline:<br />chkOffline.Checked = true;<br />break;<br />case FileAttributes.ReadOnly:<br />chkReadOnly.Checked = true;<br />break; <br />case FileAttributes.System:<br />chkSystem.Checked = true;<br />break;<br />case FileAttributes.Temporary:<br />chkTemporary.Checked = true;<br />break;<br /><br />}<br />} 

</code>

Thanks Guys

And please it's my First article , so may be have mistake any category in the viewer, so please tell any suggestions to me via email

Thanks Enjoy!!!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Ravenet

Software Developer

Singapore Singapore

Member

- B.Sc. degree in Computer Science.
- 4+ years experience in Visual C#.net and VB.net
- Obsessed in OOP style design and programming.
- Designing and developing Network security tools.
- Designing and developing a client/server application for sharing files among users in a way other than FTP protocol.
- Designing and implementing GSM gateway applications and bulk messaging.
- Windows Mobile and Symbian Programming
- Having knowledge with ERP solutions
 
The summary of my skills:
C#, VB.Net#,ASP.net, VC++, Java, WPF,WCF, Oracle, SQL Server, MS Access, Windows NT administration
 
Cheers
RRave
MCPD,MCTS
http://codegain.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionEr....source code? Pinmembersharpiesharpie2:12 26 Feb '07  
AnswerRe: Er....source code? PinmemberRavenet4:15 26 Feb '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 26 Feb 2007
Article Copyright 2007 by Ravenet
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid