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


C# DirectoryInfo.ToString方法代码示例

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


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

示例1: CopyAll

    /// <summary>
    /// Recursive Copy Directory Method
    /// </summary>
    private static void CopyAll(DirectoryInfo source, DirectoryInfo target)
    {
        // Check if the source directory exists, if not, don't do any work.
        if (!Directory.Exists(source.FullName))
        {
            return;
        }

        // Check if the target directory exists, if not, create it.
        if (!Directory.Exists(target.FullName))
        {
            Directory.CreateDirectory(target.FullName);
        }

        // Copy each file into it’s new directory.
        foreach (var fileInfo in source.GetFiles())
        {
            fileInfo.CopyTo (Path.Combine (target.ToString (), fileInfo.Name), true);
        }

        // Copy each subdirectory using recursion.
        foreach (var subDirInfo in source.GetDirectories())
        {
            DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(subDirInfo.Name);
            CopyAll(subDirInfo, nextTargetSubDir);
        }
    }
开发者ID:Fertogo,项目名称:Rox-Star,代码行数:30,代码来源:KinectCopyPluginDataHelper.cs

示例2: CopyAll

    /// <summary>
    /// Verzeichnis rekursiv kopieren. Vorhandene Dateien werden überschreiben
    /// </summary>
    /// <param name="source">QuellVERZEICHNIS</param>
    /// <param name="target">ZielVERZEICHNIS</param>
    /// <param name="dirCount">für jedes erzeugte Verzeichnis +=1</param>
    /// <param name="fileCount">für jede erzeugte Datei +=1</param>
    public static void CopyAll(
		DirectoryInfo source,
		DirectoryInfo target,
		ref int dirCount,
		ref int fileCount)
    {
        // Check if the target directory exists, if not, create it.
        if (!Directory.Exists(target.FullName))
        {
            dirCount++;
            Directory.CreateDirectory(target.FullName);
            Logger.Log("Verzeichnis erstellt: " + target.FullName);
        }

        // Copy each file into it’s new directory.
        foreach (FileInfo fi in source.GetFiles())
        {
            fileCount++;
            fi.CopyTo(Path.Combine(target.ToString(), fi.Name), true);
            Logger.Log("Datei kopiert: " + fi.FullName);
        }

        // Copy each subdirectory using recursion.
        foreach (DirectoryInfo diSrcSubDir in source.GetDirectories())
        {
            dirCount++;
            DirectoryInfo diNext = target.CreateSubdirectory(diSrcSubDir.Name);
            CopyAll(diSrcSubDir, diNext, ref dirCount, ref fileCount);
        }
    }
开发者ID:Jonas90,项目名称:iss,代码行数:37,代码来源:FileHelper.cs

示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string url = Request.Url.ToString();
        ArrayList list = new ArrayList();
        string str = string.Empty;
        DirectoryInfo dir = new DirectoryInfo(Server.MapPath(""));
        string filepath = dir.ToString().Replace("Facility", "app_offline.htm");

        if (url.IndexOf("status") != -1)
        {
            string query = Request.QueryString["status"].ToString();
            switch (query.ToUpper())
            {
                case "GET":
                    {
                        Config config = new Config();
                        config.PrintConfig1 = IMonitorConfig.GetSetting("print1");
                        config.PrintConfig2 = IMonitorConfig.GetSetting("print2");
                        config.RouterConfig = IMonitorConfig.GetSetting("router");
                        config.LaptopConfig = IMonitorConfig.GetSetting("laptop");
                        list.Add(config);
                    }
                    break;
                case "SET":
                    {
                        if (!File.Exists(filepath))
                        {
                            using (FileStream fs = File.Create(filepath))
                            {
                                fs.WriteByte(0);
                            }
                        }
                        File.Delete(filepath);
                        string print1 = Request.QueryString["print1"].ToString();
                        string print2 = Request.QueryString["print2"].ToString();
                        string router = Request.QueryString["router"].ToString();
                        string laptop = Request.QueryString["laptop"].ToString();
                        string[] name = { "print1", "print2", "router", "laptop" };
                        string[] value = { print1, print2, router, laptop };
                        IMonitorConfig.WriteSetting(name, value);
                        Response.Write("更新成功!");
                        Response.End();
                        return;
                    }
            }
        }
        else
        {
            Response.Write("This is Iwooo Monitor System");
            Response.End();
            return;
        }

        JavaScriptSerializer json = new JavaScriptSerializer();
        str = json.Serialize(list);

        Response.Write(str);
        Response.End();
        return;
    }
开发者ID:Ni9e,项目名称:IMonitor,代码行数:60,代码来源:ConfigJSON.aspx.cs

示例4: SerializeDeserialize_Roundtrip

 public void SerializeDeserialize_Roundtrip()
 {
     var orig = new DirectoryInfo("SomePath");
     DirectoryInfo cloned = BinaryFormatterHelpers.Clone(orig);
     Assert.Equal(orig.Name, cloned.Name);
     Assert.Equal(orig.FullName, cloned.FullName);
     Assert.Equal(orig.ToString(), cloned.ToString());
 }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:Serialization.cs

示例5: path

 public static string path()
 {
     string returnpath = "";
     DirectoryInfo ParentDirectory = new DirectoryInfo(Application.dataPath);
     ParentDirectory = ParentDirectory.Parent;
     returnpath = ParentDirectory.ToString();
     returnpath = returnpath + "/Resources/"+"Items/";
     Debug.Log(returnpath);
     return returnpath;
 }
开发者ID:Velantine,项目名称:Testgroud,代码行数:10,代码来源:DataPool.cs

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

示例7: OnPostProcessBuild

    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
        Debug.Log("Post Processing Build");

        // Get Required Paths
        projectParent = Directory.GetParent(Application.dataPath);
        buildname = Path.GetFileNameWithoutExtension(path);
        targetdir = Directory.GetParent(path);
        char divider = Path.DirectorySeparatorChar;
        string dataMarker = "_Data"; // Specifically for Windows Standalone build
        buildDataDir = targetdir.FullName + divider + buildname + dataMarker + divider;

        // Do Certain actions on your files (Copy, remove or email them to NASA your decision)
        filecount = 0;
        dircount = 0;
        CopyAll(new DirectoryInfo(projectParent.ToString() + divider + srcName), new DirectoryInfo(buildDataDir));

        Debug.Log("Copied: " + filecount + " file" +((filecount!=1)?"s":"")+ ", " + dircount + " folder" +((dircount!=1)?"s":""));
    }
开发者ID:GiwrgosRov,项目名称:TeamProject,代码行数:19,代码来源:CopyToBuild.cs

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

示例9: PerformDeepCopy

	static void PerformDeepCopy(string sourceDirectory, string destinationDirectory)
	{
		if (!Directory.Exists(destinationDirectory))
		{
			Directory.CreateDirectory(destinationDirectory);
		}
		
		var sourceDir = new DirectoryInfo(sourceDirectory);
		var targetDir = new DirectoryInfo(destinationDirectory);
		
		foreach (FileInfo f in sourceDir.GetFiles())
		{
			if(f.Extension != ".meta")
			{
				String file = Path.Combine(targetDir.ToString(), f.Name);
				try
				{
					f.CopyTo(file, true);
				}
				catch(Exception e)
				{
					Debug.LogError(e.Message);
					allFilesExists = false;
				}
				
				if(!File.Exists(file))
				{
					allFilesExists = false;
				}
			}
		}
		
		foreach (DirectoryInfo dir in sourceDir.GetDirectories())
		{
			var subDirectory = targetDir.CreateSubdirectory(dir.Name);
			PerformDeepCopy(dir.FullName, subDirectory.FullName);
		}
	}
开发者ID:dongvanhung,项目名称:HA3D,代码行数:38,代码来源:Deploy.cs

示例10: 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;
			strLoc = "Loc_t987b";
			dir2 = new DirectoryInfo(".");
			iCountTestcases++;
			if(File.Exists(dir2.ToString())) {
				iCountErrors++;
				printerr( "Error_94939! Incorrect return");
			}		
			dir2 = new DirectoryInfo("BogusNAmeHere");
			iCountTestcases++;
			if(File.Exists(dir2.ToString())) {
				iCountErrors++;
				printerr( "Error_029uv! Incorrect return");
			}
		} 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,代码行数:38,代码来源:co5657get_isfile.cs

示例11: DeleteFiles

    /// <summary>
    /// 删除指定文件夹下所有文件 
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>
    public static bool DeleteFiles(string path)
    {
        if (Directory.Exists(path) == false)
            {
                MessageBox.Show("Path is not Existed!");
                return false;
            }
            DirectoryInfo dir = new DirectoryInfo(path);
            FileInfo[] files = dir.GetFiles();
            try
            {
                foreach (var item in files)
                {
                    File.Delete(item.FullName);
                }
                if (dir.GetDirectories().Length != 0)
                {
                    foreach (var item in dir.GetDirectories())
                    {
                        if (!item.ToString().Contains("$") && (!item.ToString().Contains("Boot")))
                        {
                            // Console.WriteLine(item);

                            DeleteFiles(dir.ToString() + "\\" + item.ToString());
                        }
                    }
                }
                //Directory.Delete(path);
                return true;
            }
            catch (Exception)
            {
                MessageBox.Show("Delete Failed!");
                return false;

            }
    }
开发者ID:lovelll,项目名称:KMLToSHPBatch,代码行数:42,代码来源:FileManage.cs

示例12: CopyAll

    /// <summary>
    /// Recursive Copy Directory Method
    /// </summary>
    public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
    {
        // Check if the target directory exists, if not, create it.
        if (Directory.Exists(target.FullName) == false)
        {
            dircount++;
            Directory.CreateDirectory(target.FullName);
        }

        // Copy each file into it’s new directory.
        foreach (FileInfo fi in source.GetFiles())
        {
            filecount++;
            fi.CopyTo(Path.Combine(target.ToString(), fi.Name), true);
        }

        // Copy each subdirectory using recursion.
        foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
        {
            dircount++;
            DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name);
            CopyAll(diSourceSubDir, nextTargetSubDir);
        }
    }
开发者ID:GiwrgosRov,项目名称:TeamProject,代码行数:27,代码来源:CopyToBuild.cs

示例13: ValidDirectory

 public void ValidDirectory()
 {
     string path = GetTestFilePath();
     var info = new DirectoryInfo(path);
     Assert.Equal(path, info.ToString());
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:6,代码来源:ToString.cs

示例14: CurrentDirectory

 public void CurrentDirectory()
 {
     string path = ".";
     var info = new DirectoryInfo(path);
     Assert.Equal(Path.GetFileName(Directory.GetCurrentDirectory()), info.ToString());
 }
开发者ID:jmhardison,项目名称:corefx,代码行数:6,代码来源:ToString.cs

示例15: TestToString

		public void TestToString()
		{
			var fi = new DirectoryInfo(longPathDirectory);

			Assert.AreEqual(fi.DisplayPath, fi.ToString());
		}
开发者ID:HMartyrossian,项目名称:LongPath,代码行数:6,代码来源:DirectoryInfoTests.cs


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