public string CheckRepoPathAndName(string localpath, string reponame)
{
try
{
// Check whether foldername is already in use
int index = Program.Controller.Folders.FindIndex(x => x.Equals(reponame, StringComparison.OrdinalIgnoreCase));
if ( index != -1)
throw new ArgumentException(String.Format(Properties_Resources.FolderAlreadyInUse, localpath, Program.Controller.Folders[index]));
// Check whether folder name contains invalid characters.
Regex regexRepoName = (Path.DirectorySeparatorChar.Equals('\\')) ? RepositoryRegex : RepositoryRegexLinux;
if (!regexRepoName.IsMatch(reponame)||CmisSync.Lib.Utils.IsInvalidFolderName(reponame.Replace(Path.DirectorySeparatorChar, ' ')))
throw new ArgumentException(String.Format(Properties_Resources.InvalidRepoName, reponame));
// Validate localpath
if(localpath.EndsWith(Path.DirectorySeparatorChar.ToString()))
localpath = localpath.Substring(0,localpath.Length-1);
if (CmisSync.Lib.Utils.IsInvalidFolderName(Path.GetFileName(localpath)))
throw new ArgumentException(String.Format(Properties_Resources.InvalidFolderName, Path.GetFileName(localpath)));
// If no warning handler is registered, handle warning as error
if (LocalPathExists == null)
CheckRepoPathExists(localpath);
UpdateAddProjectButtonEvent(true);
return String.Empty;
}
catch (Exception e)
{
UpdateAddProjectButtonEvent(false);
return e.Message;
}
}