如何修剪文本文件的前3个字符并保存 [英] How do I trim the first 3 characters of a text file and save

查看:112
本文介绍了如何修剪文本文件的前3个字符并保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有文本文件XX_TRCSAB_123456.txt我想将文件重命名为TRCSAB_123456.txt



你能指导我如何在C sharp

I have the Text file XX_TRCSAB_123456.txt I want to Rename the file as TRCSAB_123456.txt

Can you guide me how to achieve this in C sharp

推荐答案

File.Move



https://msdn.microsoft.com/en-us/ library / system.io.file.move(v = vs.110).aspx [ ^ ]


尝试
string oldNameFullPath = "XX_TRCSAB_123456.txt";
var index = oldNameFullPath.indexOf('_');
var newNameFullPath = oldNameFullPath.substring(index, oldNameFullPath.Length - index); 
System.IO.File.Move(oldNameFullPath, newNameFullPath);


这篇关于如何修剪文本文件的前3个字符并保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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