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:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace DemoonWCFservice
{
[ServiceContract]
public interface IFiletransfer
{
[OperationContract]
void Getfile();
}
}
i have implemented this method in Filetransfer class
code for Filetransfer:
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
{
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.