Upload Single file to FTP Server using C#.net
public static bool UploadSingleFiles(string fileName,int candidateId,int resumeId)
{
try
{
string parentDir = string.Empty;
string candir = string.Empty;
string desPath = string.Empty;
FileInfo objfileInfo = new FileInfo(fileName);
parentDir = ClsConfigurations.ReadSetting("Folder");
candir = @"/" + parentDir + "/" + Convert.ToString(candidateId);
desPath = candir +"-" + Convert.ToString(resumeId) + objfileInfo.Extension;
CreateDirectory(candir);
objFTPCon.ServerDirectory = candir.Trim();
objFTPCon.UploadFile(fileName, desPath);
return true;
}
catch (Exception ex)
{
Program.WriteLog(ex.Message, ex.StackTrace);
return false;
}
}