Upload Multiple files into FTP Server using C#.Net
public static bool MultipleUploadFiles(string[] fileName, int candidateId, int resumeId)
{
try
{
string parentDir = string.Empty;
string candir = string.Empty;
string desPath = string.Empty;
foreach (string fName in fileName)
{
FileInfo objfileInfo = new FileInfo(fName);
parentDir = ClsConfigurations.ReadSetting("Folder");
candir = @"/" + parentDir + "/" + Convert.ToString(candidateId);
desPath = candir + "-" + Convert.ToString(resumeId) + objfileInfo.Extension;
CreateDirectory(candir);
objFTPCon.ServerDirectory = candir.Trim();
objFTPCon.UploadFile(fName, desPath);
}
return true;
}
catch (Exception ex)
{
Program.WriteLog(ex.Message, ex.StackTrace);
return false;
}
}
{
try
{
string parentDir = string.Empty;
string candir = string.Empty;
string desPath = string.Empty;
foreach (string fName in fileName)
{
FileInfo objfileInfo = new FileInfo(fName);
parentDir = ClsConfigurations.ReadSetting("Folder");
candir = @"/" + parentDir + "/" + Convert.ToString(candidateId);
desPath = candir + "-" + Convert.ToString(resumeId) + objfileInfo.Extension;
CreateDirectory(candir);
objFTPCon.ServerDirectory = candir.Trim();
objFTPCon.UploadFile(fName, desPath);
}
return true;
}
catch (Exception ex)
{
Program.WriteLog(ex.Message, ex.StackTrace);
return false;
}
}