记录一些经验

学习,生活

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
http://www.cnblogs.com/singlepine/archive/2006/03/05/343304.html
using System;
using System.IO;
using System.Text;

namespace Document.Bll
{
    
/// <summary>
    
/// Summary description for fileinfo.
    
/// </summary>

    public class fileinfo
    
{
        
public fileinfo()
        
{
            
//
            
// TODO: Add constructor logic here
            
//
        }

        
        
        
获取某目录下的所有文件(包括子目录下文件)的数量

        
获取某目录下的所有文件(包括子目录下文件)的大小

        
读取文件

        
写文件

        
#region System.IO.Path
        
private void System_IO_Path()
        
{
            
string path=@"c:\test\a.txt";

            
string ChangeExtension=System.IO.Path.ChangeExtension(path,".old");//更改路径字符串的扩展名。 
            string CombinePath=System.IO.Path.Combine(@"c:\","b.txt");//合并两个路径字符串。 
            string DirectoryName=System.IO.Path.GetDirectoryName(path);//返回指定路径字符串的目录信息。 
            string Extension=System.IO.Path.GetExtension(path);//返回指定的路径字符串的扩展名。 
            string FileName=System.IO.Path.GetFileName(path);//返回指定路径字符串的文件名和扩展名。 
            string FileNameWithoutExtension=System.IO.Path.GetFileNameWithoutExtension(path); //返回不具有扩展名的指定路径字符串的文件名。 
            string FullPath=System.IO.Path.GetFullPath(path);//返回指定路径字符串的绝对路径。 
            string PathRoot=System.IO.Path.GetPathRoot(path);//获取指定路径的根目录信息。 
            string TempFileName=System.IO.Path.GetTempFileName();//返回唯一临时文件名并在磁盘上通过该名称创建零字节文件。 
            string TempPath=System.IO.Path.GetTempPath();//返回当前系统的临时文件夹的路径。 
            string HasExtension=System.IO.Path.HasExtension(path).ToString();//确定路径是否包括文件扩展名。 
            string IsPathRooted=System.IO.Path.IsPathRooted(path).ToString();//获取一个值,该值指示指定的路径字符串是包含绝对路径信息还是包含相对路径信息。
        }


        
#endregion

    }

}
posted on 2007-08-31 20:37  将飞  阅读(168)  评论(0)    收藏  举报