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


C# FileInfo.CopyTo方法代码示例

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


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

示例1: CopyFile

	void CopyFile(string src_path, string tar_oath){
		string path = src_path;
		string path2 = tar_oath;
		FileInfo fi1 = new FileInfo(path);
		FileInfo fi2 = new FileInfo(path2);
		
		try 
		{
			// Create the file and clean up handles.
			using (FileStream fs = fi1.Create()) {}
			
			//Ensure that the target does not exist.
			fi2.Delete();
			
			//Copy the file.
			fi1.CopyTo(path2);
			
			//Try to copy it again, which should succeed.
			fi1.CopyTo(path2, true);

		} 
		catch 
		{

		}
	}
开发者ID:xiaopangoo,项目名称:MotionPlatform,代码行数:26,代码来源:Newtask.cs

示例2: CopyToProduct

    /// <summary>
    ///		Копирует связанные файлы
    /// </summary>
    public static void CopyToProduct(int productID, int toProductID)
    {
        //Копируем файлы только в том случае, если разботаем с буфером
            if ((productID>=0 && toProductID<0) || (productID<0 && toProductID>=0))
            {
                DataSet fileList = GetList(productID);
                if( fileList.Tables["RelatedFile"] != null )
                {
                    foreach(DataRow row in fileList.Tables["RelatedFile"].Rows)
                    {
                        //DeleteFile(Convert.ToInt32(row["rlflID"]));
                        string name = ((int)row["rlfl_ProductID"]>=0?"":"temp/") + row["rlflFileName"].ToString();
                        string extension = row["rlflFileExtension"].ToString();
                        string fileName = GetFileName(name,extension);

                        FileInfo fileInfo = new FileInfo(fileName);

                        if( fileInfo.Exists )
                        {
                            string to_name = (toProductID>=0?"":"temp/") + row["rlflFileName"].ToString();
                            string to_fileName = GetFileName(to_name,extension);

                            fileInfo.CopyTo(to_fileName, true);
                        }
                    }
                }
                SqlParameter pProductID = new SqlParameter("@ProductID", (productID>=0?(object)productID:DBNull.Value));
                SqlParameter pToProductID = new SqlParameter("@ToProductID", (toProductID>=0?(object)toProductID:DBNull.Value));
                SqlHelper.ExecuteNonQuery(m_sConnectionString, "ecom_RelatedFile_CopyToProduct", pProductID, pToProductID);
            }
    }
开发者ID:elieli,项目名称:nonProfit,代码行数:34,代码来源:DALCRelatedFile.cs

示例3: CopyToProduct

    public static void CopyToProduct(int productID, int toProductID)
    {
        DataSet fileList = GetList(productID);

            foreach(DataRow row in fileList.Tables[0].Rows)
            {
                //DeleteFile(Convert.ToInt32(row["rlflID"]));
                string name = ((int)row["_ProductID"]>=0?"":"temp/") + row["ExampleImageName"].ToString();
                string fileName = GetFileName(name, string.Empty);

                FileInfo fileInfo = new FileInfo(fileName);

                if( fileInfo.Exists )
                {
                    string to_name = (toProductID>=0?"":"temp/") + row["ExampleImageName"].ToString();
                    string to_fileName = GetFileName(to_name, string.Empty);

                    fileInfo.CopyTo(to_fileName, true);
                }
            }

            SqlParameter pProductID = new SqlParameter("@ProductID", (productID>=0?(object)productID:DBNull.Value));
            SqlParameter pToProductID = new SqlParameter("@ToProductID", (toProductID>=0?(object)toProductID:DBNull.Value));
            SqlHelper.ExecuteNonQuery(m_sConnectionString, "ecom_ProductPersField_CopyToProduct", pProductID, pToProductID);
    }
开发者ID:elieli,项目名称:nonProfit,代码行数:25,代码来源:DALCProductPersField.cs

示例4: WithNoWeaving

    public void WithNoWeaving()
    {
        var sourceProjectFile = new FileInfo(@"TestProjects\ProjectWithNoWeaving.csproj");
        var targetFileInfo = sourceProjectFile.CopyTo(sourceProjectFile.FullName + "ProjectInjectorTests", true);
        try
        {

            var injector = new CosturaProjectInjector
                           	{
                           		ToolsDirectory = @"Tools\",
                           		ProjectFile = targetFileInfo.FullName,
                           		TargetPath = "Foo.dll",
                           		Overwrite = false,
                           		IncludeDebugSymbols = false,
                           		DeleteReferences = false,
                           		MessageImportance = MessageImportance.High,
                           	};
            injector.Execute();

            var reader = new ProjectReader(targetFileInfo.FullName);

            Assert.IsFalse(reader.Overwrite.Value);
            Assert.IsFalse(reader.IncludeDebugSymbols.Value);
            Assert.IsFalse(reader.DeleteReferences.Value);
            Assert.AreEqual("Foo.dll", reader.TargetPath);
            Assert.AreEqual(@"Tools\", reader.ToolsDirectory);
            Assert.AreEqual(MessageImportance.High, reader.MessageImportance);
        }
        finally
        {
            targetFileInfo.Delete();
        }
    }
开发者ID:sachhi,项目名称:costura,代码行数:33,代码来源:ProjectInjectorTests.cs

示例5: Main

    public static void Main(string[] args)
    {
        FileInfo file = new FileInfo(@"..\..\CopyDelete.cs");
        string fullPath =file.FullName;
        DirectoryInfo dir = new DirectoryInfo(@"..\..\");
        dir.CreateSubdirectory("backup");
        DirectoryInfo backupDir = new DirectoryInfo(@"..\..\backup");
        foreach (FileInfo subfile in backupDir.GetFiles())
        {
            subfile.Delete();
        }
        file.CopyTo(@"..\..\backup\CopyDelete_Backup.cs");

        DirectoryInfo tempDir = new DirectoryInfo(@"..\..\temp");
        tempDir.Create();
        FileInfo tempFile = new FileInfo(@"..\..\temp\temp.txt");
        FileStream fs = tempFile.Create();

        fs.Close();
        tempFile.Delete();
        tempDir.Delete(true);

        Console.WriteLine("All done.");
        Console.ReadLine();
    }
开发者ID:Nagato23,项目名称:CsBasic,代码行数:25,代码来源:CopyDelete.cs

示例6: OverwriteFile

	// Copy or overwrite destination file with source file.
	public static bool OverwriteFile(string srcFilePath, string destFilePath)
	{
		FileInfo fi = new FileInfo(srcFilePath);
		if ( ! fi.Exists )
        {
        	UnityEngine.Debug.LogError(string.Format("Wwise: Failed to overwrite. Source is missing: {0}.", srcFilePath));
    		return false;
        }

		DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(destFilePath));
		
		if ( ! di.Exists )
        {
            di.Create();
        }

        const bool IsToOverwrite = true;
        try
        {
        	fi.CopyTo(destFilePath, IsToOverwrite);		
    	}
    	catch (Exception ex)
        {
			UnityEngine.Debug.LogError(string.Format("Wwise: Error during installation: {0}.", ex.Message));
			return false;
        }

        return true;
	}	
开发者ID:juliendeville,项目名称:Lunatic,代码行数:30,代码来源:AkUnityPluginInstallerBase.cs

示例7: WithNoWeaving

    public void WithNoWeaving()
    {
        var sourceProjectFile = new FileInfo(@"TestProjects\ProjectWithNoWeaving.csproj");
        var targetFileInfo = sourceProjectFile.CopyTo(sourceProjectFile.FullName + "ProjectReaderTest", true);
        try
        {

            var reader = new ProjectReader(targetFileInfo.FullName);

            Assert.IsNull(reader.DependenciesDirectory);
            Assert.IsNull(reader.ToolsDirectory);
            Assert.IsNull(reader.CheckForEquality);
            Assert.IsNull(reader.CheckForIsChanged);
            Assert.IsNull(reader.ProcessFields);
            Assert.IsNull(reader.MessageImportance);
            Assert.IsNull(reader.TryToWeaveAllTypes);
            Assert.IsNull(reader.EventInvokerName);
            Assert.IsNull(reader.EventInvokerName);
            Assert.IsNull(reader.TargetPath);
            Assert.IsNull(reader.TargetNode);
            Assert.IsNull(reader.DependenciesDirectory);
        }
        finally
        {
            targetFileInfo.Delete();
        }
    }
开发者ID:Z731,项目名称:NotifyPropertyWeaver,代码行数:27,代码来源:ProjectReaderTests.cs

示例8: CopyFile

        /// <exception cref="System.IO.IOException"></exception>
        public static void CopyFile(FileInfo sourceFile, FileInfo destFile)
        {
            if (!File.Exists(destFile.FullName))
            {
                File.Open (destFile.FullName, FileMode.CreateNew).Close ();
            }

            sourceFile.CopyTo(destFile.FullName);
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:10,代码来源:FileDirUtils.cs

示例9: MenuBackupInput

 public static void MenuBackupInput()
 {
     FileInfo fi = new FileInfo(@"ProjectSettings/InputManager.asset");
     if (fi.Exists)
     {
     #if UNITY_3_5
         string dest = @"Assets/Ouya/ProjectSettings/3.X/InputManager.asset";
         fi.CopyTo(dest, true);
         Debug.Log(string.Format("{0} Succesfully backed up: {1}", DateTime.Now, dest));
         AssetDatabase.ImportAsset(dest.Replace(@"\", "/"));
     #elif UNITY_4_0_0 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
         string dest = @"Assets/Ouya/ProjectSettings/4.X/InputManager.asset";
         fi.CopyTo(dest, true);
         Debug.Log(string.Format("{0} Succesfully backed up: {1}", DateTime.Now, dest));
         AssetDatabase.ImportAsset(dest.Replace(@"\", "/"));
     #endif
     }
 }
开发者ID:skytiger,项目名称:ouya-unity-plugin,代码行数:18,代码来源:OuyaMenuAdmin.cs

示例10: LoadCubiquity

    public bool LoadCubiquity(TargetInfo Target)
    {
        bool isLibrarySupported = false;

        if((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
        {
            isLibrarySupported = true;

            string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "Win64" : "Win32";

            //string remotePath = @"http://www.volumesoffun.com/downloads/Cubiquity/Cubiquity-2015-06-14.zip";
            //System.IO.Compression.ZipFile.ExtractToDirectory(remotePath, extractPath);

            //Copy the Cubiquity DLL into the binaries directory locally
            FileInfo file = new FileInfo(Path.Combine(ThirdPartyLibraryPath, "CubiquityC.dll"));
            DirectoryInfo destDir = new DirectoryInfo(Path.Combine(ModulePath, "..", "..", "Binaries", PlatformString));
            destDir.Create();
            FileInfo destFile = new FileInfo(Path.Combine(destDir.ToString(), "CubiquityC.dll"));
            if (destFile.Exists)
            {
                if (file.LastWriteTime > destFile.LastWriteTime)
                {
                    file.CopyTo(destFile.FullName, true);
                }
            }
            else
            {
                file.CopyTo(destFile.FullName, true);
            }

            //Make sure we can link against the .lib file
            PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyLibraryPath, "CubiquityC.lib"));
        }

        if(isLibrarySupported)
        {
            // Include path
            PublicIncludePaths.Add(ThirdPartyIncludePath);
        }

        return isLibrarySupported;
    }
开发者ID:jvanegmond,项目名称:cubiquity-for-unreal-engine,代码行数:42,代码来源:Cubiquity.Build.cs

示例11: down_ServerClick

 protected void down_ServerClick(object sender, EventArgs e)
 {
     var now = Server.MapPath("../Common/物资/条码/打包/{0}.zip".Formatted((sender as HtmlInputButton).Attributes["match"]));
     var name = CleanInvalidFileName((sender as HtmlInputButton).Attributes["matchx"]);
     name += "_" + DateTime.UtcNow.Ticks.ToString();
     var next = Server.MapPath("../Common/物资/条码/打包/{0}.zip".Formatted(name));
     var fi = new FileInfo(now);
     fi.CopyTo(next, true);
     var script = "window.open('../Common/物资/条码/打包/{0}.zip','_blank');".Formatted(name);
     ap.ResponseScripts.Add(script);
 }
开发者ID:Homory-Temp,项目名称:LeYi,代码行数:11,代码来源:CodeList.aspx.cs

示例12: Main

 public static void Main(string[] args)
 {
     FileInfo f = new FileInfo(args[0]);
     Console.WriteLine("Name: "+f.Name);
     Console.WriteLine("Full name: "+f.FullName);
     Console.WriteLine("Creation time: "+f.CreationTime);
     Console.WriteLine("Last access time: "+f.LastAccessTime);
     Console.WriteLine("Length: "+f.Length);
     Console.WriteLine("Parent directory: "+f.DirectoryName);
     FileInfo output = f.CopyTo(args[1]);
 }
开发者ID:JnS-Software-LLC,项目名称:CSC153,代码行数:11,代码来源:FileProperties+(1).cs

示例13: CopyFile

    /// <summary>
    /// Datei source ins Verzeichnis target kopieren. Überschreibt vorhandene
    /// Dateien.
    /// </summary>
    /// <param name="source">QuellDATEI</param>
    /// <param name="target">ZielVERZEICHNIS</param>
    /// <param name="fileCount">wird um 1 erhöht, wenn erfolgreich</param>
    public static void CopyFile(
		FileInfo source,
		DirectoryInfo target,
		ref int fileCount)
    {
        if (source.Exists)
        {
            fileCount++;
            source.CopyTo(Path.Combine(target.ToString(), source.Name), true);
            Logger.Log("Datei kopiert: " + source.FullName);
        }
        else
        {
            Logger.LogError("Datei nicht gefunden: " + source.FullName);
        }
    }
开发者ID:Jonas90,项目名称:iss,代码行数:23,代码来源:FileHelper.cs

示例14: UTomateDemoInstaller

    static UTomateDemoInstaller()
    {
        string installationRoot = Application.dataPath + "/uTomate Demo/Editor";
        string installerFiles = installationRoot+"/InstallerFiles";
        FileInfo dllFile = new FileInfo (installationRoot + "/uTomateDemo.dll");
        FileInfo sourceFile = new FileInfo (installerFiles + "/" + DLL_SRC_NAME);

        // Check if the DLL is missing and if we got a matching source file. If so
        // copy over the matching source file to the DLL name.
        if (!dllFile.Exists && sourceFile.Exists) {
            Debug.Log ("Installing correct uTomate DLL file for current Unity version " + Application.unityVersion);
            sourceFile.CopyTo (dllFile.FullName);
            Debug.Log ("Installation complete. If you switch unity versions please delete " +
                       dllFile.FullName + ". This installer will then run again.");
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
        }
    }
开发者ID:odbb,项目名称:uTomate-UnityCloudBuildSample,代码行数:17,代码来源:UTomateDemoInstaller.cs

示例15: WithMinimalWeaving

 public void WithMinimalWeaving()
 {
     var sourceProjectFile = new FileInfo(@"TestProjects\ProjectWithMinimalWeaving.csproj");
     var targetFileInfo = sourceProjectFile.CopyTo(sourceProjectFile.FullName + "ProjectReaderTest", true);
     try
     {
         var reader = new ProjectReader(targetFileInfo.FullName);
         Assert.IsNull(reader.Overwrite);
         Assert.IsNull(reader.IncludeDebugSymbols);
         Assert.IsNull(reader.DeleteReferences);
         Assert.IsNull(reader.TargetPath);
         Assert.AreEqual(@"$(SolutionDir)Tools\", reader.ToolsDirectory);
         Assert.IsNull(reader.MessageImportance);
     }
     finally
     {
         targetFileInfo.Delete();
     }
 }
开发者ID:MartinDemberger,项目名称:Costura,代码行数:19,代码来源:ProjectReaderTests.cs


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