Advertisement

C#开发文件重命名功能的两种方法

阅读量:

近期由于项目需求,需完成一项文件重命名的操作。鉴于以往长期使用powershell进行相关操作,因此首先考虑的是借助powershell中的“ren”指令来实现该功能。

随后自行编写了一个简易的测试示例,具体内容如下所示。

复制代码
 using System;

    
 using System.IO;
    
 using System.Management.Automation;
    
 using System.Runtime.InteropServices;
    
  
    
  
    
 namespace testBitOFCPU
    
 {
    
     class Program
    
     {
    
     static void Main(string[] args)
    
     {
    
         
    
        string target = @"C:\Users\wangqx\Desktop\11.txt";
    
        string fileName = "11";
    
        string fileDirectory = Path.GetDirectoryName(target);
    
  
    
        string suf

全部评论 (0)

还没有任何评论哟~