如何使用out文件名修剪文件路径 [英] How to trim a file path with out file name

查看:74
本文介绍了如何使用out文件名修剪文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从此文件路径中删除文件名...



例如: - D:\Official\JitheshA \Projects \TestingTool \ Attachments\1099\1081\Chrysanthemum.jpg





ANS:D:\Official\JitheshA \ Projects\TestingTool\Attachments\1099\1081 \





问候

Jithesh A

I want to remove the file name from this file path...

Eg:- D:\Official\JitheshA\Projects\TestingTool\Attachments\1099\1081\Chrysanthemum.jpg


ANS: D:\Official\JitheshA\Projects\TestingTool\Attachments\1099\1081\


Regards
Jithesh A

推荐答案

尝试:

Try:
string fullPath = @"D:\Official\JitheshA\Projects\TestingTool\Attachments\1099\1081\Chrysanthemum.jpg";
string pathOnly = Path.GetDirectoryName(fullPath);


你想得到目录名。



Path.GetDirectoryName会帮助你。

例如

You want to get the directory name.

Path.GetDirectoryName will help you.
e.g.
string directory = Path.GetDirectoryName(fileName);



如需了解更多示例,请点击此处查看:

http://www.dotnetperls.com/path [ ^ ]


这篇关于如何使用out文件名修剪文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆