Advertisement
Anonim_ID

Rename File Masal

Nov 3rd, 2014
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. /*
  2.     http://aang-notes.blogspot.com/
  3. */
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.IO;
  9. namespace rename_file_masal {
  10.     class Program {
  11.         static void Main(string[] args) {
  12.             string pathFolder = @"path folder";
  13.             string namaBaru = "";
  14.             foreach (string filenya in Directory.GetFiles(pathFolder)) {
  15.                 namaBaru = Path.GetFileName(filenya).Replace("teks", "");
  16.  
  17.                 try {
  18.                     File.Move(filenya, pathFolder + namaBaru);
  19.                     Console.ForegroundColor = ConsoleColor.Green;
  20.                     Console.WriteLine("File " + filenya + " Berhasil direname!");
  21.                 } catch (Exception errr) {
  22.                     Console.ForegroundColor = ConsoleColor.Red;
  23.                     Console.WriteLine("File " + filenya + " gagal direname! (" + errr.Message + ")");
  24.                 }
  25.             }
  26.             Console.WriteLine("Operasi telah selesai!");
  27.             Console.ReadKey();
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement