Пример #1
0
        /// <summary>
        /// Creates a folder nodes physical directory
        /// Override if your node does not use file system folder
        /// </summary>
        /// <param name="newName"></param>
        /// <returns></returns>
        public virtual void CreateDirectory(string newName)
        {
            if (String.IsNullOrEmpty(newName))
            {
                throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "newName");
            }

            try
            {
                // on a new dir && enter, we get called with the same name (so do nothing if name is the same
                char[] dummy = new char[1];
                dummy[0] = Path.DirectorySeparatorChar;
                string oldDir = this.Url;
                oldDir = oldDir.TrimEnd(dummy);
                string strNewDir = Path.Combine(Path.GetDirectoryName(oldDir), newName);

                if (String.Compare(strNewDir, oldDir, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    if (Directory.Exists(strNewDir))
                    {
                        throw new InvalidOperationException(SR.GetString(SR.DirectoryExistError, CultureInfo.CurrentUICulture));
                    }
                    Directory.CreateDirectory(strNewDir);
                }
            }
            //TODO - this should not digest all exceptions.
            catch (System.Exception e)
            {
                CCITracing.Trace(e);
                throw;
            }
        }
Пример #2
0
 /// <summary>
 /// creates the physical directory for a folder node
 /// Override if your node does not use file system folder
 /// </summary>
 public virtual void CreateDirectory()
 {
     try
     {
         if (Directory.Exists(this.Url) == false)
         {
             Directory.CreateDirectory(this.Url);
         }
     }
     //TODO - this should not digest all exceptions.
     catch (System.Exception e)
     {
         CCITracing.Trace(e);
         throw;
     }
 }