CmisSync.Lib.Utils.CreateConflictFilename C# (CSharp) Метод

CreateConflictFilename() публичный статический Метод

Find an available conflict free filename for this file. For instance: - if /dir/file does not exist, return the same path - if /dir/file exists, return /dir/file (1) - if /dir/file (1) also exists, return /dir/file (2) - etc
public static CreateConflictFilename ( String path, String user ) : string
path String Path of the file in conflict
user String Local user
Результат string
        public static string CreateConflictFilename(String path, String user)
        {
            if (!File.Exists(path))
            {
                return path;
            }
            else
            {
                string extension = Path.GetExtension(path);
                string filepath = path.Substring(0, path.Length - extension.Length);
                string ret = String.Format("{0}_{1}-conflict-version{2}", filepath, user, extension);
                if (!File.Exists(ret))
                    return ret;
                int index = 1;
                do
                {
                    ret = String.Format("{0}_{1}-conflict-version ({2}){3}", filepath, user, index.ToString(), extension);
                    if (!File.Exists(ret))
                    {
                        return ret;
                    }
                    index++;
                }
                while (true);
            }
        }