none
i have stuck in c# coding for which i have to extract txt file and store in .bat file extention in given path RRS feed

  • Question

  • using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.IO;

    namespace batfile
    {
        class Program
        {
            static void Main(string[] args)
            {
                string[] lines = File.ReadAllLines(@"C:\vijay\batfile.txt");

            }
        }
    }
    Wednesday, December 5, 2018 4:36 PM

All replies

  • Try File.WriteAllLines(@"C:\vijay\textfile.bat", lines).


    Wednesday, December 5, 2018 4:59 PM
  • So you want to copy a .txt file and rename it to a .bat file?

    var oldName = @"C:\Vijay\batfile.txt";
    var newName = Path.ChangeExtension(oldName, ".bat");
    
    //Overwrite if it exists
    File.Copy(oldName, newName, true);


    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, December 5, 2018 5:40 PM
    Moderator