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


C# System.IO.DirectoryInfo.MoveTo方法代码示例

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


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

示例1: TestFunction

		public TestFunction()
		{

			DirectoryInfo di = new System.IO.DirectoryInfo("Sample path here");;
			DirectoryInfo parent = Directory.GetParent(di.FullName);
			String newPath = Path.Combine(parent.FullName, "sample input path");

			// rename to some temp name, to help change lower and uppercast names
			di.MoveTo(newPath + "__renameTemp__");
			di.MoveTo(newPath);

			// Trying to cleanup to prevent directory locking, doesn't work...
			di = null;
			parent = null;
			GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);

                        GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                        GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                        GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);


		}
开发者ID:CodePorting,项目名称:CSharpSourceProject,代码行数:22,代码来源:1.cs

示例2: sasIntegration

 /// <summary>
 /// Constructor for class. Requires a featureClass and a string pointing to an out directory. By default the generalized logistic method is specified
 /// </summary>
 /// <param name="inFtr">Input featureClass</param>
 /// <param name="procedure">The procedure to run</param>
 public sasIntegration(IFeatureClass inFtr,SasProcedure procedure)
 {
     infeatureclass = inFtr;
     p = procedure;
     o = ((IDataset)inFtr).Workspace.PathName + "\\SASOUTPUT\\" + p.ToString();
     if (System.IO.Directory.Exists(o))
     {
         System.Windows.Forms.DialogResult rslt = System.Windows.Forms.MessageBox.Show(p.ToString() + " folder already exists. Do you want to rename the existing " + p.ToString()+" outputs (If you select no existing outputs will be lost)?", "Existing Directory", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
         if (rslt == System.Windows.Forms.DialogResult.Yes)
         {
             string newOutName = getNewName(o);
             System.IO.DirectoryInfo dInfo = new System.IO.DirectoryInfo(o);
             dInfo.MoveTo(newOutName);
             updateOldSasFile(newOutName);
         }
     }
     geoUtil.check_dir(o);
     if (!System.IO.File.Exists(sasexe))
     {
         System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
         ofd.DefaultExt = ".exe";
         ofd.Filter = "SAS Executable|*.exe";
         ofd.Title = "Can't find SAS exe!";
         ofd.Multiselect = false;
         System.Windows.Forms.DialogResult rslt = ofd.ShowDialog();
         if (rslt == System.Windows.Forms.DialogResult.OK)
         {
             sasexe = ofd.FileName;
             esriUtil.Properties.Settings.Default.SASEXE = sasexe;
             esriUtil.Properties.Settings.Default.Save();
         }
         else
         {
             sasexe = null;
         }
     }
     prStInfo = pr.StartInfo;
     prStInfo.CreateNoWindow = true;
     prStInfo.UseShellExecute = false;
     prStInfo.FileName = sasexe;
     prStInfo.Arguments = "-sysin \"" + OutSasPath + "\" -log \"" + OutDirectory + "\" -print \"" + OutDirectory + "\"";
 }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:47,代码来源:sasIntegration.cs

示例3: BuildXml

		protected override void BuildXml()
		{
			if ( Request.Form["CKFinderCommand"] != "true" )
			{
				ConnectorException.Throw( Errors.InvalidRequest );
			}

			if ( !this.CurrentFolder.CheckAcl( AccessControlRules.FolderRename ) )
			{
				ConnectorException.Throw( Errors.Unauthorized );
			}

			// The root folder cannot be deleted.
			if ( this.CurrentFolder.ClientPath == "/" )
			{
				ConnectorException.Throw( Errors.InvalidRequest );
				return;
			}

			string newFileName = Request[ "NewFolderName" ];

			if ( !Connector.CheckFolderName( newFileName ) || Config.Current.CheckIsHiddenFolder( newFileName ) )
			{
				ConnectorException.Throw( Errors.InvalidName );
				return;
			}

			// Get the current folder.
			System.IO.DirectoryInfo oDir = new System.IO.DirectoryInfo( this.CurrentFolder.ServerPath );

			bool bMoved = false;

			try
			{
				if ( !oDir.Exists )
					ConnectorException.Throw( Errors.InvalidRequest );
				else
				{
					// Build the new folder path.
					string newFolderPath = System.IO.Path.Combine( oDir.Parent.FullName, newFileName );

					if ( System.IO.Directory.Exists( newFolderPath ) || System.IO.File.Exists( newFolderPath ) )
						ConnectorException.Throw( Errors.AlreadyExist );

					oDir.MoveTo( newFolderPath );
					bMoved = true;
				}
			}
			catch ( System.UnauthorizedAccessException )
			{
				ConnectorException.Throw( Errors.AccessDenied );
			}
			catch ( System.Security.SecurityException )
			{
				ConnectorException.Throw( Errors.AccessDenied );
			}
			catch ( System.ArgumentException )
			{
				ConnectorException.Throw( Errors.InvalidName );
			}
			catch ( System.NotSupportedException )
			{
				ConnectorException.Throw( Errors.InvalidName );
			}
			catch ( System.IO.PathTooLongException )
			{
				ConnectorException.Throw( Errors.InvalidName );
			}
			catch ( System.IO.IOException )
			{
				ConnectorException.Throw( Errors.Unknown );
			}
			catch ( ConnectorException connectorException )
			{
				throw connectorException;
			}
			catch
			{
#if DEBUG
				throw;
#else
				ConnectorException.Throw( Errors.Unknown );
#endif
			}

			if ( bMoved )
			{
				try
				{
					// Get the thumbnails folder.
					System.IO.DirectoryInfo oThumbsDir = new System.IO.DirectoryInfo( this.CurrentFolder.ThumbsServerPath );

					// Build the new folder path.
					string newThumbsFolderPath = System.IO.Path.Combine( oThumbsDir.Parent.FullName, newFileName );

					if ( System.IO.Directory.Exists( newThumbsFolderPath ) )
					{
						System.IO.File.Delete( this.CurrentFolder.ThumbsServerPath );
					}
					else
//.........这里部分代码省略.........
开发者ID:mohsenboojari,项目名称:offwind,代码行数:101,代码来源:RenameFolderCommandHandler.cs

示例4: Main


//.........这里部分代码省略.........
                        diL = null;
                        now = System.DateTime.Now;
                        diL = di.GetDirectories ();
                    } catch (Exception e) {
                        exc = e;
                    } finally {
                        outFile.WriteLine ("Name: " + tempPath + "\\TestDir3");
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.GetDirectories()");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                        outFile.WriteLine ("Time: " + GetTime (now));
                        outFile.WriteLine ("Retv: " + toString (diL));
                        outFile.WriteLine ("Errc: " + "");
                        outFile.WriteLine ("Exce: " + GetException (exc));
                    }
                    try {
                        exc = null;
                        fsiL = null;
                        now = System.DateTime.Now;
                        fsiL = di.GetFileSystemInfos ();
                    } catch (Exception e) {
                        exc = e;
                    } finally {
                        outFile.WriteLine ("Name: " + tempPath + "\\TestDir3");
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.GetFileSystemInfos()");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                        outFile.WriteLine ("Time: " + GetTime (now));
                        outFile.WriteLine ("Retv: " + toString (fsiL));
                        outFile.WriteLine ("Errc: " + "");
                        outFile.WriteLine ("Exce: " + GetException (exc));
                    }
                    try {
                        exc = null;
                        now = System.DateTime.Now;
                        di.MoveTo (tempPath + "\\TestDir4");
                    } catch (Exception e) {
                        exc = e;
                    } finally {
                        outFile.WriteLine ("Name: " + tempPath + "\\TestDir3");
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.MoveTo(String)");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                        outFile.WriteLine ("Time: " + GetTime (now));
                        outFile.WriteLine ("Retv: " + "");
                        outFile.WriteLine ("Errc: " + "");
                        outFile.WriteLine ("Exce: " + GetException (exc));
                        //---
                        outFile.WriteLine ("Name: " + tempPath + "\\TestDir4");
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.MoveTo(String)");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                        outFile.WriteLine ("Time: " + GetTime (now));
                        outFile.WriteLine ("Retv: " + "");
                        outFile.WriteLine ("Errc: " + "");
                        outFile.WriteLine ("Exce: " + GetException (exc));
                    }
                } finally {
                    try {
                        exc = null;
                        char[] backSlash = new char[1];
                        backSlash[0] = '\\';
                        outFile.WriteLine ("Name: " + di.FullName.TrimEnd (backSlash));
                        now = System.DateTime.Now;
                        di.Delete ();
                    } catch  (Exception e) {
                        exc = e;
                    } finally {
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.Delete()");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
开发者ID:uvbs,项目名称:Holodeck,代码行数:67,代码来源:TestApplication4.cs


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