Rename and Copy only Word Document files from one folder to another

Vasanth
 
on Sep 25, 2012 03:40 AM
3501 Views

Hi

I have more than one word file in a folder.

In that word file i have to replace the ","(comma) with "-"(slash) and need to save the file in the other location.

Thanks.

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mudassar
 
on Sep 25, 2012 06:34 AM

This way

        string[] files = Directory.GetFiles(Server.MapPath("~/Uploads/"), "*.doc");
        foreach(string file in files)
        {
            File.Copy(file, Server.MapPath("~/Uploads_New/") + Path.GetFileName(file).Replace(",", "-"));
        }