分享

C# 文件路径、文件名、扩展名

 遥远的桥zz 2011-04-30

string filePath = @"E:\Randy0528\中文目录\JustTest.rar";
Response.Write(
"文件路径:"+filePath);
Response.Write(
"<br/>更改路径字符串的扩展名。<br/>");
Response.Write(System.IO.Path.ChangeExtension(filePath,
"txt"));
Response.Write(
"<br/>返回指定路径字符串的目录信息。。<br/>");
Response.Write(System.IO.Path.GetDirectoryName(filePath));
Response.Write(
"<br/>返回指定的路径字符串的扩展名。<br/>");
Response.Write(System.IO.Path.GetExtension(filePath));
Response.Write(
"<br/>返回指定路径字符串的文件名和扩展名。<br/>");
Response.Write(System.IO.Path.GetFileName(filePath));
Response.Write(
"<br/>返回不具有扩展名的指定路径字符串的文件名。<br/>");
Response.Write(System.IO.Path.GetFileNameWithoutExtension(filePath));
Response.Write(
"<br/>获取指定路径的根目录信息。<br/>");
Response.Write(System.IO.Path.GetPathRoot(filePath));
Response.Write(
"<br/>返回随机文件夹名或文件名。<br/>");
Response.Write(System.IO.Path.GetRandomFileName());
Response.Write(
"<br/>创建磁盘上唯一命名的零字节的临时文件并返回该文件的完整路径。<br/>");
Response.Write(System.IO.Path.GetTempFileName());
Response.Write(
"<br/>返回当前系统的临时文件夹的路径。<br/>");
Response.Write(System.IO.Path.GetTempPath());
Response.Write(
"<br/>确定路径是否包括文件扩展名。<br/>");
Response.Write(System.IO.Path.HasExtension(filePath));
Response.Write(
"<br/>获取一个值,该值指示指定的路径字符串是包含绝对路径信息还是包含相对路径信息。<br/>");
Response.Write(System.IO.Path.IsPathRooted(filePath));

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多