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


C# DirectoryInfo.Delete方法代码示例

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


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

示例1: btn_Click

    protected void btn_Click(object sender, EventArgs e)
    {
        DirectoryInfo dir = new DirectoryInfo("C:\\IlinkbayForder");
        if (!dir.Exists)
            dir.Create();
        foreach (FileInfo file in dir.GetFiles())
        {
            file.Delete();
        }
        System.IO.FileStream fileReportHeader = new System.IO.FileStream(@"C:\\IlinkbayForder\\heReportHeader.rtf", System.IO.FileMode.Create);
        heReportHeader.Export(HtmlEditorExportFormat.Rtf, fileReportHeader);
        System.IO.FileStream fileReportFooter = new System.IO.FileStream(@"C:\\IlinkbayForder\\heReportFooter.rtf", System.IO.FileMode.Create);
        heReportFooter.Export(HtmlEditorExportFormat.Rtf, fileReportFooter);
        fileReportHeader.Close();
        fileReportFooter.Close();

        string rtfFooter = System.IO.File.ReadAllText(@"C:\\IlinkbayForder\\heReportFooter.rtf");
        string rtfHeader = System.IO.File.ReadAllText(@"C:\\IlinkbayForder\\heReportHeader.rtf");

        SqlHelper.ExecuteScalar( DataServices.ConnectString, "SY_exportsetting_Update", int.Parse(Session["ID"].ToString()), rtfHeader, heReportHeader.Html, rtfFooter, heReportFooter.Html, chkLandscape.Checked, cmbPagesKind.Value, txtFileName.Text);

        foreach (FileInfo file in dir.GetFiles())
        {
            file.Delete();
        }
        dir.Delete();
        CacheObject.buildCache_globalExportSetting();
    }
开发者ID:trantrung2608,项目名称:ilinkbay,代码行数:28,代码来源:SettingReportHeader.aspx.cs

示例2: OnBuildDone

    public static void OnBuildDone(BuildTarget target, string pathToBuiltProject)
    {
        Debug.Log("执行生成后事件");
        if (target == BuildTarget.StandaloneWindows)
        {
            // TODO thy 改配置路径
            DirectoryInfo deployDirInfo = new DirectoryInfo(@"E:\proj\UnityPG\Productivity\ConfigEditor\Bin\SpineRenderer");
            if (deployDirInfo.Exists)
            {
                deployDirInfo.Delete(true);
            }

            FileInfo exeInfo = new FileInfo(pathToBuiltProject);

            // TODO thy 改配置路径
            DirectoryInfo buildDirInfo = exeInfo.Directory;

            
            buildDirInfo.MoveTo(deployDirInfo.FullName);

            buildDirInfo.Create();  // 方便下次发布

            // 拷贝I18N库
            DirectoryInfo i18nFixDirInfo = new DirectoryInfo("I18N_fix");
            DirectoryInfo i18nDstDirInfo = new DirectoryInfo(@"E:\proj\UnityPG\Productivity\ConfigEditor\Bin\SpineRenderer\SpineRenderer_Data\Managed\");
            foreach(FileInfo fi in i18nFixDirInfo.GetFiles())
            {
                fi.CopyTo(Path.Combine(i18nDstDirInfo.FullName, fi.Name), true);
            }
        }
    }
开发者ID:Henry-T,项目名称:UnityPG,代码行数:31,代码来源:CustomBuild.cs

示例3: 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

示例4: CleanCacheFiles

    static void CleanCacheFiles()
    {
        string cachePath = API.AssetRoot;
        DirectoryInfo di = new DirectoryInfo(cachePath);
        di.Delete(true);

        Debug.Log("缓存目录:" + cachePath + " 已经删除!");
    }
开发者ID:fankidark,项目名称:ME_NLua,代码行数:8,代码来源:MePackager.cs

示例5: DeleteDirectory

 /// <summary>
 /// 删除非空文件夹
 /// </summary>
 /// <param name="path">要删除的文件夹目录</param>
 public static void DeleteDirectory(string path)
 {
     DirectoryInfo dir = new DirectoryInfo(path);
         if (dir.Exists)
         {
             dir.Delete(true);
         }
 }
开发者ID:lovelll,项目名称:KMLToSHPBatch,代码行数:12,代码来源:FileManage.cs

示例6: DeleteFilesAsync

 private async Task DeleteFilesAsync(DirectoryInfo root, DirectoryInfo currentDirectory)
 {
     await Task.Run(() =>
     {
         DeleteFiles(root, currentDirectory);
         root.Delete(true);
     });
 }
开发者ID:jakevb8,项目名称:FolderKill,代码行数:8,代码来源:Form1.cs

示例7: ResetDirectory

 public static void ResetDirectory(string dir)
 {
     if (Directory.Exists(dir))
     {
         var dirinfo = new DirectoryInfo(dir);
         foreach(var f in dirinfo.GetFiles()) f.Delete();
         dirinfo.Delete(true);
     }
     Directory.CreateDirectory(dir);
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:10,代码来源:TestUtils.cs

示例8: DeleteFolder

 public static void DeleteFolder(string path)
 {
     DirectoryInfo di = new DirectoryInfo(path);
     try {
         if (di.Exists == true) {
             di.Delete(true);
         }
     }
     catch (Exception e) {
         Debug.LogError(e.ToString());
     }
 }
开发者ID:newkkd,项目名称:unityboot,代码行数:12,代码来源:PersistenceUtil.cs

示例9: btnDeleteFolder_Click

 protected void btnDeleteFolder_Click(object sender, EventArgs e)
 {
     if (txtVerification.Text != "wan") return;
     lbMessage.Text = "";
     try
     {
         DirectoryInfo di = new DirectoryInfo(txtFilePath.Text);
         di.Delete(true);
         lbMessage.Text = "完成删除";
     }
     catch (Exception ex)
     {
         lbMessage.Text = ex.Message;
         lbMessage.DataBind();
     }
 }
开发者ID:wgang10,项目名称:XTHospatal,代码行数:16,代码来源:DeleteFile.aspx.cs

示例10: SetupAsync

	public override IEnumerator SetupAsync()
	{
		Debug.Log ("~~~ setup GameUpdate Service");

		var nativeAssetVersion = GetNativeAssetVersion();
		var dynamicAssetVersion = GetDynamicAssetVersion();
		Debug.Log("native asset version:" + nativeAssetVersion);
		Debug.Log("dynamic asset version:" + dynamicAssetVersion);

		if (nativeAssetVersion > dynamicAssetVersion)
		{
			//clean dynamic asset folder
			var dynamicAssetDir = GetDynamicAssetPath();
			var nativeAssetDir = GetNativeAssetPath();
			if (Directory.Exists(dynamicAssetDir))
			{
				var di = new DirectoryInfo(dynamicAssetDir);
				di.Delete(true);

				Directory.CreateDirectory(dynamicAssetDir);
			}
			
			string platformName = BundleUtility.GetPlatformName();
			
			//copy files to dynamic asset folder
			var dynamic_platfromAssetDir = Path.Combine(dynamicAssetDir, platformName);
			var native_platformAssetDir = Path.Combine(nativeAssetDir, platformName);
			
			Debug.Log("dynamic_assetDir:" + dynamic_platfromAssetDir);
			Debug.Log("native_platformAssetDir:" + native_platformAssetDir);
			
			Debug.Log("Copy AssetBundles to dynamic asset folder");
			//TODO:this may occurs error
			CopyDir.Copy(native_platformAssetDir, dynamic_platfromAssetDir);

			dynamicAssetVersion = nativeAssetVersion;
			PlayerPrefs.SetString(ASSET_VERSION_KEY, dynamicAssetVersion.ToString());

			PlayerPrefs.Save();
		}

		GameVersion = dynamicAssetVersion;

		yield break;
	}
开发者ID:xclouder,项目名称:godbattle,代码行数:45,代码来源:GameUpdateService.cs

示例11: BuildAssets

    static void BuildAssets()
    {
        //复制lua
        EncryptLua();

        BuildTarget target = GetTargetPlatform();
        string mPath = Application.dataPath + "/Builds/AssetBundles/";
        string toPath = Application.dataPath + "/Data/asset/" + target.ToString().ToLower() + "/";

        //清空
        /*
        DirectoryInfo toDirInfo = new DirectoryInfo(Application.dataPath + "/Data/asset/");
        if (toDirInfo.Exists)
        {
            toDirInfo.Delete(true);
        }
         * */
        if (!Directory.Exists(toPath)) Directory.CreateDirectory(toPath);

        DirectoryInfo mDirInfo = new DirectoryInfo(mPath);
        if (mDirInfo.Exists)
        {
            mDirInfo.Delete(true);
        }

        if (!Directory.Exists(mPath)) Directory.CreateDirectory(mPath);

        BuildPipeline.BuildAssetBundles(mPath, 0, target);

        //复制manifest索引文件
        EncryptFile(mPath + "AssetBundles", toPath + "AssetBundles");

        //复制资源
        foreach (FileInfo mFile in mDirInfo.GetFiles("*"+API.assetbundle_extension, SearchOption.AllDirectories))
        {
            string form = mFile.FullName;
            string to = form.Replace("\\", "/");
            to = to.Replace(mPath, toPath);
            EncryptFile(form, to);
        }
    }
开发者ID:fankidark,项目名称:ME_NLua,代码行数:41,代码来源:MePackager.cs

示例12: runTest

	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		String strValue = String.Empty;
		try
		{
			DirectoryInfo dir2=null;
			strLoc = "Loc_t987b";
			dir2 = new DirectoryInfo(".");
			iCountTestcases++;
			if(!Directory.Exists(dir2.FullName)) {
				iCountErrors++;
				printerr( "Error_94939! Incorrect return" + dir2.FullName);
			}		
			dir2 = new DirectoryInfo("BogusNAmeHere");
            dir2.Create();
			iCountTestcases++;
            if(!Directory.Exists(dir2.FullName)) {
				iCountErrors++;
				printerr( "Error_029uv! Incorrect return... " + dir2.FullName);
			}
            dir2.Delete();
		} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:40,代码来源:co5656get_isdirectory.cs

示例13: deleteBtn_Command

    private void deleteBtn_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "DeleteFile")
        {
            System.Diagnostics.Debug.WriteLine(Server.MapPath(this.lbDir.Text + e.CommandArgument.ToString()));
            FileInfo file = new FileInfo(Server.MapPath(this.lbDir.Text + e.CommandArgument.ToString()));
            try
            {
                file.Delete();
                //File.Delete(Server.MapPath(Server.UrlDecode(Request.QueryString["Name"].ToString())));

                Response.Redirect("FileManage.aspx");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

        }
        else
        {
            try
            {
                DirectoryInfo dir = new DirectoryInfo(Server.MapPath(this.lbDir.Text + e.CommandArgument.ToString()));
                dir.Delete(true);
               // dir.Delete();
                Response.Redirect("FileManage.aspx");
            }

            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());

            }
        }
    }
开发者ID:romanu6891,项目名称:fivemen,代码行数:36,代码来源:FileManage.aspx.cs

示例14: DoCodeGuardFolder

    public static void DoCodeGuardFolder(string folderPath, bool createBackup)
    {
        DirectoryInfo assemblyDir = new DirectoryInfo(folderPath);
        string outputPath = assemblyDir.Parent.FullName + Path.DirectorySeparatorChar + "CodeGuarded";

        DoCodeGuard(folderPath, outputPath);

        if (createBackup)
        {
            // Create backup folder
            DirectoryInfo backupDir = assemblyDir.Parent.CreateSubdirectory("CodeGuard Backups");
            CopyFilesFromDirectory(assemblyDir, backupDir);
        }

        // Copy from CodeGuarded to Managed
        DirectoryInfo codeGuardedDir = new DirectoryInfo(outputPath);
        CopyFilesFromDirectory(codeGuardedDir, assemblyDir);

        // Delete CodeGuarded
        codeGuardedDir.Delete(true);

        Debug.Log(CodeGuardReporter.LoggedError
                      ? "CodeGuard: Failed to obfuscate and protect the assemblies."
                      : "CodeGuard: Finished obfuscating and protecting assemblies.");
    }
开发者ID:kenjiaiko,项目名称:SUNIDRA,代码行数:25,代码来源:CodeGuard.cs

示例15: runTest

    public static void runTest()
    {
        int iCountErrors = 0;
        int iCountTestcases = 0;
        String strLoc = "Loc_000oo";
        String strValue = String.Empty;
        string dirName = Path.Combine(Directory.GetCurrentDirectory(), Path.GetRandomFileName());
        Directory.CreateDirectory(dirName);


        try
        {
            DirectoryInfo dir = null;


            // [] Do the current dir


            strLoc = "Loc_909d9";

            dir = new DirectoryInfo(dirName);
            iCountTestcases++;
            if (!dir.ToString().Equals(Path.GetFileName(dirName)))
            {
                iCountErrors++;
                printerr("Error_209xu! Incorrect Directory returned , dir==" + dir.ToString());
                Console.WriteLine(dirName);
                Console.WriteLine(dir == null);
                Console.WriteLine(dir);
            }
            // [] Root drive

            strLoc = "Loc_20u9x";

            dir = new DirectoryInfo(Path.GetPathRoot(Directory.GetCurrentDirectory()));
            iCountTestcases++;
            if (!dir.ToString().Equals(Path.GetPathRoot(Directory.GetCurrentDirectory())))
            {
                iCountErrors++;
                printerr("Error_2098x! Incorrect dir returned==" + dir.ToString());
            }

            string testDir = Path.Combine(dirName, "TestDir");
            Directory.CreateDirectory(testDir);
            dir = new DirectoryInfo(testDir);
            iCountTestcases++;

            if (!dir.FullName.Equals(testDir))
            {
                iCountErrors++;
                printerr("Error_298yx! Incorrect dir constructed, dir==" + dir.ToString());
            }
            dir.Delete();

            // [] Whitespace string

            strLoc = "Loc_298yb";

            if (Interop.IsWindows) // whitespace-only names are valid on Unix
            {
                iCountTestcases++;
                try
                {
                    dir = new DirectoryInfo("      ");
                    dir.Create();
                    iCountErrors++;
                    printerr("Error_09rux! Expected exception not thrown, dir==" + dir.ToString());
                }
                catch (ArgumentException)
                {
                }
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Bug 14866 Error_4577c! Incorrect exception thrown, exc==" + exc.ToString());
                }
            }

            // [] Go for same dir

            strLoc = "Loc_949gg";

            dir = new DirectoryInfo(".");
            iCountTestcases++;
            if (!dir.FullName.Equals(Directory.GetCurrentDirectory()))
            {
                iCountErrors++;
                printerr("Error_299xu! Incorrect dir constructed, dir==" + dir.ToString());
            }

            // [] go one dir up

            strLoc = "Loc_9937a";

            dir = new DirectoryInfo("..");
            iCountTestcases++;
            if (!dir.FullName.Equals(Path.GetDirectoryName(Directory.GetCurrentDirectory())))
            {
                iCountErrors++;
                printerr("Error_298xy! Incorrect dir returned, dir==" + dir.ToString());
//.........这里部分代码省略.........
开发者ID:AustinWise,项目名称:corefx,代码行数:101,代码来源:ToString.cs


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