zoukankan      html  css  js  c++  java
  • 【转】C# 对路径的一些操作

    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));

    文件路径:E:Randy0528中文目录JustTest.rar
    更改路径字符串的扩展名。
    E:Randy0528中文目录JustTest.txt
    返回指定路径字符串的目录信息。。
    E:Randy0528中文目录
    返回指定的路径字符串的扩展名。
    .rar
    返回指定路径字符串的文件名和扩展名。
    JustTest.rar
    返回不具有扩展名的指定路径字符串的文件名。
    JustTest
    获取指定路径的根目录信息。
    E:
    返回随机文件夹名或文件名。
    ct2h5b2h.sed
    创建磁盘上唯一命名的零字节的临时文件并返回该文件的完整路径。
    C:Documents and SettingsRandyLocal SettingsTemp mpAD.tmp
    返回当前系统的临时文件夹的路径。
    C:Documents and SettingsRandyLocal SettingsTemp
    确定路径是否包括文件扩展名。
    True
    获取一个值,该值指示指定的路径字符串是包含绝对路径信息还是包含相对路径信息。
    True

  • 相关阅读:
    [转]asp.net core中的View Component
    [转] 三层架构、MVC
    [转]Javascript异步编程之三Promise: 像堆积木一样组织你的异步流程
    T4语法快速入门
    [转]ASP.NET Core 十种方式扩展你的 Views
    (装机)关于WINRE/ESP/LRS_ESP/MSR/PBR这些分区
    C#设计模式系列目录
    [转]RESTful API 设计指南
    .gitignore释疑
    [转]Subdirectory Checkouts with git sparse-checkout
  • 原文地址:https://www.cnblogs.com/cfsxgogogo/p/5051529.html
Copyright © 2011-2022 走看看