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


C# IDirectory.Create方法代码示例

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


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

示例1: CopyTo

        /// <summary>
        /// Copy "this" directory (<paramref name="a_this"/>) to the given destination directory (<paramref name="a_destination"/>).
        /// </summary>
        /// <param name="a_this">"This" directory.</param>
        /// <param name="a_destination">Destination directory.</param>
        /// <exception cref="NullReferenceException">Thrown if <paramref name="a_this"/> is null.</exception>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="a_destination"/> is null.</exception>
        public static void CopyTo(this IDirectory a_this, IDirectory a_destination)
        {
            #region Argument Validation

            if (a_this == null)
                throw new NullReferenceException(nameof(a_this));

            if (a_destination == null)
                throw new ArgumentNullException(nameof(a_destination));

            #endregion

            a_destination.Create();

            foreach (var file in a_this.Files())
            {
                var dest = a_destination.File(file.Name);
                file.CopyTo(dest);
            }

            foreach (var directory in a_this.Directories())
            {
                var dest = a_destination.Directory(directory.Name);
                directory.CopyTo(dest);
            }
        }
开发者ID:jsmunroe,项目名称:Helpers,代码行数:33,代码来源:DirectoryHelpers.cs

示例2: ServiceModelCodeGenerator

        protected ServiceModelCodeGenerator(IDirectory directory, CodeGenerationOptions options)
        {
            this.Options = options;
            this.directory = directory;

            directory.Create(true);
        }
开发者ID:techpub,项目名称:Fickle,代码行数:7,代码来源:ServiceModelCodeGenerator.cs

示例3: Create

		/// <summary>
		/// 	Creates a junction point from the specified directory to the specified target directory.
		/// </summary>
		/// <remarks>
		/// 	Only works on NTFS.
		/// </remarks>
		/// <param name = "junctionPoint">The junction point path</param>
		/// <param name = "targetDir">The target directory</param>
		/// <param name = "overwrite">If true overwrites an existing reparse point or empty directory</param>
		/// <exception cref = "IOException">Thrown when the junction point could not be created or when
		/// 	an existing directory was found and <paramref name = "overwrite" /> if false</exception>
		public static void Create(IDirectory junctionPoint, string targetDir, bool overwrite)
		{
			//targetDir = Path.GetFullPath(targetDir);

			if (!Directory.Exists(targetDir))
				throw new IOException("Target path does not exist or is not a directory.");

			if (junctionPoint.Exists)
			{
				if (!overwrite)
					throw new IOException("Directory already exists and overwrite parameter is false.");
			}
			else
				junctionPoint.Create();

			using (var handle = OpenReparsePoint(junctionPoint.Path.FullPath, EFileAccess.GenericWrite))
			{
				var targetDirBytes = Encoding.Unicode.GetBytes(NonInterpretedPathPrefix + Path.GetFullPath(targetDir));

				var reparseDataBuffer = new REPARSE_DATA_BUFFER();

				reparseDataBuffer.ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
				reparseDataBuffer.ReparseDataLength = (ushort) (targetDirBytes.Length + 12);
				reparseDataBuffer.SubstituteNameOffset = 0;
				reparseDataBuffer.SubstituteNameLength = (ushort) targetDirBytes.Length;
				reparseDataBuffer.PrintNameOffset = (ushort) (targetDirBytes.Length + 2);
				reparseDataBuffer.PrintNameLength = 0;
				reparseDataBuffer.PathBuffer = new byte[0x3ff0];
				Array.Copy(targetDirBytes, reparseDataBuffer.PathBuffer, targetDirBytes.Length);

				var inBufferSize = Marshal.SizeOf(reparseDataBuffer);
				var inBuffer = Marshal.AllocHGlobal(inBufferSize);

				try
				{
					Marshal.StructureToPtr(reparseDataBuffer, inBuffer, false);

					int bytesReturned;
					var result = DeviceIoControl(handle.DangerousGetHandle(), FSCTL_SET_REPARSE_POINT,
					                             inBuffer, targetDirBytes.Length + 20, IntPtr.Zero, 0, out bytesReturned, IntPtr.Zero);

					if (!result)
						ThrowLastWin32Error("Unable to create junction point.");
				}
				finally
				{
					Marshal.FreeHGlobal(inBuffer);
				}
			}
		}
开发者ID:hammett,项目名称:Castle.Transactions,代码行数:61,代码来源:JunctionPoint.cs

示例4: TemporaryDirectory

		public TemporaryDirectory(IDirectory unerlyingDirectory)
		{
			UnderlyingDirectory = unerlyingDirectory;
			if (!UnderlyingDirectory.Exists)
				UnderlyingDirectory.Create();
		}
开发者ID:bittercoder,项目名称:Windsor,代码行数:6,代码来源:TemporaryDirectory.cs

示例5: DirectoryMigrationsLibrary

 public DirectoryMigrationsLibrary(IDirectory getDirectoryInfo = null)
 {
     _getDirectoryInfo = getDirectoryInfo;
     if (_getDirectoryInfo != null) _getDirectoryInfo.Create();
 }
开发者ID:mcintyre321,项目名称:Sourcery,代码行数:5,代码来源:DirectoryMigrationsLibrary.cs


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