Hi,
We transfer files into a temporary folder, and then rename it to the current build number, so to do this, we were storing the ServerDirectory in a var, changing up, and then finding the name of that folder with GetFileInfos(), as follows:
[code]
string currentDestinationPath = FtpClient.ServerDirectory;
FtpClient.ChangeWorkingDirectoryUp();
FTPFile[] allFiles = FtpClient.GetFileInfos();
int i = 0;
for (i = 0; i < allFiles.Length && (allFiles[i].Path != currentDestinationPath); i++);
string folderToRename = allFiles[i].Name;
[/code]
This works fine, except on a client's Linux server, where GetFileInfos() (for some reason) appends "//" after the name, which means that we never find the folder in our loop. I presume this is simply the server's behaviour and there's nothing we can do about it?
So we're re-writing this code and wanted to ask which was a better solution, 1) passing a path into RenameFile or 2) passing just the folder name:
1.
[code]
RenameDir(string newFolderName)
{
string currentDestinationPath = FtpClient.ServerDirectory;
FtpClient.ChangeWorkingDirectoryUp();
FtpClient.RenameFile(currentDestinationPath, FtpClient.ServerDirectory +"/"+ newFolderName);
}
[/code]
2.
[code]
RenameDir(string newFolderName)
{
string currentDestinationPath = FtpClient.ServerDirectory;
FtpClient.ChangeWorkingDirectoryUp();
FtpClient.RenameFile(currentDestinationPath, newFolderName);
}
[/code]
Or, will it effectively amount to the same thing on Linux/Unix servers?
Do you have any other suggestions as to the safest method of doing this?
Thanks,
Graeme