当前位置: 首页>>代码示例>>C#>>正文


C# IFolder.CreateFolder方法代码示例

本文整理汇总了C#中IFolder.CreateFolder方法的典型用法代码示例。如果您正苦于以下问题:C# IFolder.CreateFolder方法的具体用法?C# IFolder.CreateFolder怎么用?C# IFolder.CreateFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFolder的用法示例。


在下文中一共展示了IFolder.CreateFolder方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UploadFolderRecursively

            /// <summary>
            /// Upload folder recursively.
            /// After execution, the hierarchy on server will be: .../remoteBaseFolder/localFolder/...
            /// </summary>
            private bool UploadFolderRecursively(IFolder remoteBaseFolder, string localFolder)
            {
                bool success = true;
                SleepWhileSuspended();

                IFolder folder = null;
                try
                {
                    var syncItem = database.GetFolderSyncItemFromLocalPath(localFolder);
                    if (null == syncItem)
                    {
                        syncItem = SyncItemFactory.CreateFromLocalPath(localFolder, repoinfo);
                    }
                    // Create remote folder.
                    Dictionary<string, object> properties = new Dictionary<string, object>();
                    properties.Add(PropertyIds.Name, syncItem.RemoteFileName);
                    properties.Add(PropertyIds.ObjectTypeId, "cmis:folder");
                    properties.Add(PropertyIds.CreationDate, Directory.GetCreationTime(localFolder));
                    properties.Add(PropertyIds.LastModificationDate, Directory.GetLastWriteTime(localFolder));
                    try
                    {
                        Logger.Debug(String.Format("Creating remote folder {0} for local folder {1}", syncItem.RemoteFileName, localFolder));
                        folder = remoteBaseFolder.CreateFolder(properties);
                        Logger.Debug(String.Format("Created remote folder {0}({1}) for local folder {2}", syncItem.RemoteFileName, folder.Id ,localFolder));
                    }
                    catch (CmisNameConstraintViolationException)
                    {
                        foreach (ICmisObject cmisObject in remoteBaseFolder.GetChildren())
                        {
                            if (cmisObject.Name == syncItem.RemoteFileName)
                            {
                                folder = cmisObject as IFolder;
                            }
                        }
                        if (folder == null)
                        {
                            Logger.Warn("Remote file conflict with local folder " + syncItem.LocalFileName);
                            // TODO Show error message
                            return false;
                        }
                        success = false;
                    }
                    catch (Exception e)
                    {
                        ProcessRecoverableException(String.Format("Exception when create remote folder for local folder {0}: {1}", localFolder, e.Message), e);
                        return false;
                    }


                    // Create database entry for this folder
                    // TODO Add metadata
                    database.AddFolder(syncItem, folder.Id, folder.LastModificationDate);
                    Logger.Info("Added folder to database: " + localFolder);
                }
                catch (CmisBaseException e)
                {
                    ProcessRecoverableException("Could not create remote directory: " + remoteBaseFolder.Path + "/" + Path.GetFileName(localFolder), e);
                    return false;
                }

                try
                {
                    // Upload each file in this folder.
                    foreach (string file in Directory.GetFiles(localFolder))
                    {
                        if (Utils.WorthSyncing(localFolder, Path.GetFileName(file), repoinfo))
                        {
                            success &= UploadFile(file, folder);
                        }
                    }

                    // Recurse for each subfolder in this folder.
                    foreach (string subfolder in Directory.GetDirectories(localFolder))
                    {
                        if (Utils.WorthSyncing(localFolder, Path.GetFileName(subfolder), repoinfo))
                        {
                            success &= UploadFolderRecursively(folder, subfolder);
                        }
                    }
                }
                catch (Exception e)
                {
                    ProcessRecoverableException("Could not uploading folder: " + localFolder, e);
                    return false;
                }
                return success;
            }
开发者ID:jelacote,项目名称:CmisSync,代码行数:91,代码来源:SynchronizedFolder.cs

示例2: crawlLocalFolders

        /**
         * Crawl local folders in a given directory (not recursive).
         */
        private void crawlLocalFolders(string localFolder, IFolder remoteFolder, IList remoteFolders)
        {
            foreach (string folderPath in Directory.GetDirectories(localFolder))
            {
                string folderName = Path.GetFileName(folderPath);
                if (!remoteFolders.Contains(folderName))
                {
                    // This local folder is not on the CMIS server now, so
                    // check whether it used to exist on server or not.
                    if(database.ContainsFolder(folderPath))
                    {
                        // Folder has been deleted on server, delete it locally too.
                        SparkleLogger.LogInfo("Sync", "Removing remotely deleted folder: " + folderPath);
                        Directory.Delete(folderPath, true);

                        // Delete folder from database.
                        database.RemoveFolder(folderPath);
                    }
                    else
                    {
                        if (BIDIRECTIONAL)
                        {
                            // New folder, sync up.
                            Dictionary<string, object> properties = new Dictionary<string, object>();
                            properties.Add(PropertyIds.Name, folderName);
                            properties.Add(PropertyIds.ObjectTypeId, "cmis:folder");
                            IFolder folder = remoteFolder.CreateFolder(properties);

                            // Create database entry for this folder.
                            database.AddFolder(folderPath, folder.LastModificationDate);
                        }
                    }
                }
            }
        }
开发者ID:smcardle,项目名称:CmisSync,代码行数:38,代码来源:CmisDirectory.cs

示例3: CreateFolder

        public IFolder CreateFolder(IFolder folder, string name)
        {
            Dictionary<string, object> properties = new Dictionary<string, object>();
            properties.Add(PropertyIds.Name, name);
            properties.Add(PropertyIds.ObjectTypeId, "cmis:folder");

            return folder.CreateFolder(properties);
        }
开发者ID:pcreignou,项目名称:CmisSync,代码行数:8,代码来源:CmisSyncTests.cs

示例4: SetDaysFolder

        private void SetDaysFolder(event_followup_log followup, ref IFolder folder)
        {
            var date = followup.date_created.Value;
            string year = date.Year.ToString();
            string month = date.Month.ToString();
            string days = date.Day.ToString();

            if (folder.ItemExists(year))
                folder = folder.GetFolder(year);
            else
            {
                folder = folder.CreateFolder(year);
            }

            if (folder.ItemExists(month))
                folder = folder.GetFolder(month);
            else
                folder = folder.CreateFolder(month);

            if (folder.ItemExists(days))
                folder = folder.GetFolder(days);
            else
                folder = folder.CreateFolder(days);
        }
开发者ID:,项目名称:,代码行数:24,代码来源:

示例5: UploadFolderRecursively

            /// <summary>
            /// Upload folder recursively.
            /// After execution, the hierarchy on server will be: .../remoteBaseFolder/localFolder/...
            /// </summary>
            private void UploadFolderRecursively(IFolder remoteBaseFolder, string localFolder)
            {
                sleepWhileSuspended();

                IFolder folder;
                try
                {
                    // Create remote folder.
                    Dictionary<string, object> properties = new Dictionary<string, object>();
                    properties.Add(PropertyIds.Name, Path.GetFileName(localFolder));
                    properties.Add(PropertyIds.ObjectTypeId, "cmis:folder");
                    properties.Add(PropertyIds.CreationDate, Directory.GetCreationTime(localFolder));
                    properties.Add(PropertyIds.LastModificationDate, Directory.GetLastWriteTime(localFolder));
                    folder = remoteBaseFolder.CreateFolder(properties);

                    // Create database entry for this folder
                    database.AddFolder(localFolder, folder.LastModificationDate);
                    Logger.Info("Added folder to database: " + localFolder);
                }
                catch (CmisBaseException e)
                {
                    ProcessRecoverableException("Could not create remote directory: " + remoteBaseFolder.Path + "/" + Path.GetFileName(localFolder), e);
                    return;
                }

                try
                {
                    // Upload each file in this folder.
                    foreach (string file in Directory.GetFiles(localFolder))
                    {
                        if (Utils.WorthSyncing(localFolder, Path.GetFileName(file), repoinfo))
                        {
                            UploadFile(file, folder);
                        }
                    }

                    // Recurse for each subfolder in this folder.
                    foreach (string subfolder in Directory.GetDirectories(localFolder))
                    {
                        if (Utils.WorthSyncing(localFolder, Path.GetFileName(subfolder), repoinfo))
                        {
                            UploadFolderRecursively(folder, subfolder);
                        }
                    }
                }
                catch (Exception e)
                {
                    ProcessRecoverableException("Could not uploading folder: " + localFolder, e);
                }
            }
开发者ID:keithwharrison,项目名称:Oris4Sync,代码行数:54,代码来源:SynchronizedFolder.cs

示例6: UploadFolderRecursively

        /// <summary>
        /// Upload folder recursively.
        /// After execution, the hierarchy on server will be: .../remoteBaseFolder/localFolder/...
        /// </summary>
        private bool UploadFolderRecursively(IFolder remoteBaseFolder, string localFolder)
        {
            bool success = true;
            CheckPendingCancelation();

            IFolder folder = null;
            try
            {
                SyncItem syncItem = getSyncItemFromLocalPath(localFolder);

                // Create remote folder.
                Dictionary<string, object> properties = new Dictionary<string, object>();
                properties.Add(PropertyIds.Name, syncItem.RemoteFileName);
                properties.Add(PropertyIds.ObjectTypeId, "cmis:folder");
                properties.Add(PropertyIds.CreationDate, Directory.GetCreationTime(localFolder));
                properties.Add(PropertyIds.LastModificationDate, Directory.GetLastWriteTime(localFolder));
                try
                {
                    Logger.Debug(String.Format("Creating remote folder {0} for local folder {1}", syncItem.RemoteFileName, localFolder));
                    folder = remoteBaseFolder.CreateFolder(properties);
                    Logger.Debug(String.Format("Created remote folder {0}({1}) for local folder {2}", syncItem.RemoteFileName, folder.Id, localFolder));
                }
                catch (CmisNameConstraintViolationException e)
                {
                    HandleException(new DirectoryCreationRemoteFileCollisionException(syncItem.LocalFileName, e));
                    return false;
                }

                // Create database entry for this folder
                // TODO Add metadata
                database.AddFolder(syncItem, folder.Id, folder.LastModificationDate);
                Logger.Info("Added folder to database: " + localFolder);
            }
            catch (CmisBaseException e)
            {
                HandleException(new CreateRemoteDirectory(remoteBaseFolder.Path + "/" + Path.GetFileName(localFolder), e));
                return false;
            }

            try
            {
                // Upload each file in this folder.
                foreach (string file in Directory.GetFiles(localFolder))
                {
                    if (SyncUtils.IsWorthSyncing(localFolder, Path.GetFileName(file), SyncFolderInfo))
                    {
                        success &= UploadFile(file, folder);
                    }
                }

                // Recurse for each subfolder in this folder.
                foreach (string subfolder in Directory.GetDirectories(localFolder))
                {
                    if (SyncUtils.IsWorthSyncing(localFolder, Path.GetFileName(subfolder), SyncFolderInfo))
                    {
                        success &= UploadFolderRecursively(folder, subfolder);
                    }
                }
            }
            catch (Exception e)
            {
                HandleException(new UploadFolderException(localFolder, e));
                return false;
            }
            return success;
        }
开发者ID:lelmarir,项目名称:CmisSync,代码行数:70,代码来源:SyncFolderSyncronizer.cs

示例7: UploadFolderRecursively

            /// <summary>
            /// Upload folder recursively.
            /// After execution, the hierarchy on server will be: .../remoteBaseFolder/localFolder/...
            /// </summary>
            private void UploadFolderRecursively(IFolder remoteBaseFolder, string localFolder)
            {
                // Create remote folder.
                Dictionary<string, object> properties = new Dictionary<string, object>();
                properties.Add(PropertyIds.Name, Path.GetFileName(localFolder));
                properties.Add(PropertyIds.ObjectTypeId, "cmis:folder");
                IFolder folder = remoteBaseFolder.CreateFolder(properties);

                // Create database entry for this folder
                // TODO Add metadata
                database.AddFolder(localFolder, folder.LastModificationDate);

                try
                {
                    // Upload each file in this folder.
                    foreach (string file in Directory.GetFiles(localFolder))
                    {
                        if (Utils.WorthSyncing(file))
                            UploadFile(file, folder);
                    }

                    // Recurse for each subfolder in this folder.
                    foreach (string subfolder in Directory.GetDirectories(localFolder))
                    {
                        string path = subfolder.Substring(repoinfo.TargetDirectory.Length);
                        path = path.Replace("\\\\","/");
                        if (Utils.WorthSyncing(subfolder) && !repoinfo.isPathIgnored(path))
                            UploadFolderRecursively(folder, subfolder);
                    }
                }
                catch (Exception e)
                {
                    if (e is System.IO.DirectoryNotFoundException ||
                        e is IOException)
                    {
                        Logger.Warn("Folder deleted while trying to upload it, reverting.");
                        // Folder has been deleted while we were trying to upload/checksum/add.
                        // In this case, revert the upload.
                        folder.DeleteTree(true, null, true);
                    }
                    else
                    {
                        throw;
                    }
                }

            }
开发者ID:jmanuelnavarro,项目名称:CmisSync,代码行数:51,代码来源:SynchronizedFolder.cs


注:本文中的IFolder.CreateFolder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。