Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have implemented wcf service which is for transfer a file into E drive on client system.it is working for the first time is good.when i call the service from second time it showing error message like "file is already existed".
now i want to implement the service if the file is already existed in E drive i want to change the file name by adding 1 number at last to the file.
for example file name is ram.docx.
if the file existed in E drive just i want to change file name into ram1.docx
if ram1.docx file existed in E drive just i want to change file name into ram2.docx
this is what exactly i want to do.

My code is :

code for wcf interface:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace DemoonWCFservice
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IHelloservice" in both code and config file together.
    [ServiceContract]
    public interface IFiletransfer
    {
       
        [OperationContract]
        void Getfile();

    }
}


i have implemented this method in Filetransfer class

code for Filetransfer:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Web;
using System.IO;

namespace DemoonWCFservice
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Helloservice" in both code and config file together.
    public class Filetransfer : IFiletransfer
    {
        


        public void Getfile()
        {

            string source=@"D:\Swathi\DemoonWCFservice\DemoonWCFservice\Info\RAMPRADEEP KALIVARAPU (1).docx";
            string destination=@"E:\RAMPRADEEP KALIVARAPU (1).docx";
            File.Copy(source, destination);


        }
    }
}

please provide me a solution for this.
Posted
Updated 12-Oct-15 0:17am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900