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


C# DirectoryInfo.Refresh方法代码示例

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


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

示例1: CONFIGFilesDownload

 //Copy the files to the folder * .xml "Application.persistentDataPath/config"
 private IEnumerator CONFIGFilesDownload(string[] files, int CurrentFile)
 {
     string origin = Application.streamingAssetsPath + "/config/" + files [CurrentFile];
             string NewFolder = Application.persistentDataPath + "/config";
             string destinationFile = NewFolder + "/" + files [CurrentFile];
             DirectoryInfo DirNewFolder = new DirectoryInfo (NewFolder);
             DirNewFolder.Refresh ();
             if (DirNewFolder.Exists == false) {
                     DirNewFolder.Create ();
             }
             WWW www = new WWW (origin);
             yield return www;
             File.WriteAllBytes (destinationFile, www.bytes);
 }
开发者ID:pi19404,项目名称:aimlbot-for-unity,代码行数:15,代码来源:DownloadFiles.cs

示例2: InitializeExistsAfterCreation

        public void InitializeExistsAfterCreation()
        {
            string dirName = GetTestFilePath();
            DirectoryInfo di = new DirectoryInfo(dirName);

            Assert.False(di.Exists);
            Directory.CreateDirectory(dirName);

            // data should be stale
            Assert.False(di.Exists);

            // force refresh
            di.Refresh();
            Assert.True(di.Exists);
        }
开发者ID:alux-xu,项目名称:corefx,代码行数:15,代码来源:Exists.cs

示例3: runTest

    public static void runTest()
    {
        int iCountErrors = 0;
        int iCountTestcases = 0;
        String strLoc = "Loc_000oo";
        String strValue = String.Empty;


        try
        {
            /////////////////////////  START TESTS ////////////////////////////
            ///////////////////////////////////////////////////////////////////


            DirectoryInfo dir2;
            String dirName = Path.Combine(TestInfo.CurrentDirectory, Path.GetRandomFileName());

            if (Directory.Exists(dirName))
                Directory.Delete(dirName);


            // [] Delete directory and refresh
            //----------------------------------------------------------------
            strLoc = "Loc_00001";

            Directory.CreateDirectory(dirName);
            dir2 = new DirectoryInfo(dirName);
            Directory.Delete(dirName);
            iCountTestcases++;
            dir2.Refresh();

            //----------------------------------------------------------------

            // [] Change name of directory and refresh
            //----------------------------------------------------------------
            strLoc = "Loc_00005";

            string newDirName = Path.Combine(TestInfo.CurrentDirectory, "Temp001");
            if (Directory.Exists(newDirName))
                Directory.Delete(newDirName);

            iCountTestcases++;
            Directory.CreateDirectory(dirName);
            dir2 = new DirectoryInfo(dirName);
            dir2.MoveTo(newDirName);
            dir2.Refresh();
            Directory.Delete(newDirName);
            //----------------------------------------------------------------

            // [] Change Attributes and refresh
            //----------------------------------------------------------------
            strLoc = "Loc_00006";
            iCountTestcases++;

            Directory.CreateDirectory(dirName);
            dir2 = new DirectoryInfo(dirName);

            if (((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) != 0)
            {
                Console.WriteLine(dir2.Attributes);
                iCountErrors++;
                printerr("Error_00007! Attribute set before refresh");
            }
            dir2.Attributes = FileAttributes.ReadOnly;
            dir2.Refresh();
            iCountTestcases++;
            if (((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) <= 0)
            {
                iCountErrors++;
                printerr("Error_00008! Object not refreshed after setting readonly");
            }

            dir2.Attributes = new FileAttributes();
            dir2.Refresh();
            if (((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) != 0)
            {
                iCountErrors++;
                printerr("Error_00009! Object not refreshed after removing readonly");
            }

            //----------------------------------------------------------------

            if (Directory.Exists(dirName))
                Directory.Delete(dirName);

            ///////////////////////////////////////////////////////////////////
            /////////////////////////// END TESTS /////////////////////////////
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine("Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
        }
        ////  Finish Diagnostics
        if (iCountErrors != 0)
        {
            Console.WriteLine("FAiL! " + s_strTFName + " ,iCountErrors==" + iCountErrors.ToString());
        }

        Assert.Equal(0, iCountErrors);
//.........这里部分代码省略.........
开发者ID:johnhhm,项目名称:corefx,代码行数:101,代码来源:Refresh.cs

示例4: 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;
			String dirName = s_strTFAbbrev+"Dir";
			if(Directory.Exists(dirName))
			   Directory.Delete(dirName);
			strLoc = "Loc_00001";
			Directory.CreateDirectory(dirName);
			dir2 = new DirectoryInfo(dirName);
			Directory.Delete(dirName);
			iCountTestcases++;
			dir2.Refresh();
			strLoc = "Loc_00005";
			if(Directory.Exists("Temp001"))
				Directory.Delete("Temp001");
			iCountTestcases++;
			Directory.CreateDirectory(dirName);
			dir2 = new DirectoryInfo(dirName);
			dir2.MoveTo("Temp001");
			dir2.Refresh();
			Directory.Delete("Temp001");
			strLoc = "Loc_00006";
			iCountTestcases++;
			Directory.CreateDirectory(dirName);
			dir2 = new DirectoryInfo(dirName);
			Console.WriteLine(dir2.Attributes);
   			if(((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) != 0) {
				iCountErrors++;
				printerr( "Error_00007! Attribute set before refresh");
			}
			dir2.Attributes = FileAttributes.ReadOnly;                        
			dir2.Refresh();
			iCountTestcases++;
			if(((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) <= 0) {
				iCountErrors++;
				printerr( "Error_00008! Object not refreshed after setting readonly");
			}
			dir2.Attributes = new FileAttributes();
			dir2.Refresh();
   			if(((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) != 0) {
				iCountErrors++;
				printerr( "Error_00009! Object not refreshed after removing readonly");
			}
			if(Directory.Exists(dirName))
			   Directory.Delete(dirName);
		} 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:ArildF,项目名称:masters,代码行数:67,代码来源:co5767refresh.cs

示例5: r2uDir

    // Converts a rose path to a unity path and creates the directory structure of non-existent
    public static DirectoryInfo r2uDir(string rosePath, string extension = ".asset")
    {
        var roseDir = new DirectoryInfo(FixPath(rosePath).ToLower());
        string unityPath = roseDir.FullName;

        if (roseDir.Extension != "")
            unityPath = unityPath.Replace(roseDir.Extension, extension);
        else
            unityPath += extension;

        if (unityPath.Contains("3ddata"))
            unityPath = unityPath.Replace("3ddata", "GameData");

        var unityDir = new DirectoryInfo(unityPath);

        // Creat the parent folder path if it doesn't already exist
        if( !unityDir.Parent.Exists )
            Directory.CreateDirectory(unityDir.Parent.FullName);

        unityDir.Refresh();
        return unityDir;
    }
开发者ID:osROSE,项目名称:UnityRose,代码行数:23,代码来源:Utils.cs

示例6: SymLinksMayExistIndependentlyOfTarget

        public void SymLinksMayExistIndependentlyOfTarget()
        {
            var path = GetTestFilePath();
            var linkPath = GetTestFilePath();

            var pathFI = new DirectoryInfo(path);
            var linkPathFI = new DirectoryInfo(linkPath);

            pathFI.Create();
            Assert.True(MountHelper.CreateSymbolicLink(linkPath, path, isDirectory: true));

            // Both the symlink and the target exist
            pathFI.Refresh();
            linkPathFI.Refresh();
            Assert.True(pathFI.Exists, "path should exist");
            Assert.True(linkPathFI.Exists, "linkPath should exist");

            // Delete the target.  The symlink should still exist, but on Unix it'll now
            // be considered a file and won't exist as a directory.
            pathFI.Delete();
            pathFI.Refresh();
            Assert.False(pathFI.Exists, "path should now not exist");
            linkPathFI.Refresh();
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Assert.True(linkPathFI.Exists, "linkPath directory should still exist");
                Assert.False(File.Exists(linkPath), "linkPath file should not exist");

                Directory.Delete(linkPath);
            }
            else
            {
                Assert.False(linkPathFI.Exists, "linkPath directory should no longer exist");
                Assert.True(File.Exists(linkPath), "linkPath file should now exist");

                File.Delete(linkPath);
            }

            linkPathFI.Refresh();
            Assert.False(linkPathFI.Exists, "linkPath should no longer exist");
        }
开发者ID:shmao,项目名称:corefx,代码行数:41,代码来源:Exists.cs

示例7: runTest

    public static void runTest()
    {
        String strLoc = "Loc_0001";
        String strValue = String.Empty;
        int iCountErrors = 0;
        int iCountTestcases = 0;

        try
        {
            String fileName = Path.GetRandomFileName();

            // [] Valid file name and datetime(Today)
            strLoc = "Loc_0006";
            DirectoryInfo dir2 = new DirectoryInfo(fileName);
            dir2.Create();
            iCountTestcases++;
            try
            {
                dir2.LastWriteTime = DateTime.Today;
                if (!CompareDates(dir2.LastWriteTime, DateTime.Now))
                {
                    iCountErrors++;
                    printerr("Error_0007! Creation time cannot be correct");
                }
            }
            catch (Exception exc)
            {
                iCountErrors++;
                printerr("Error_0008! Unexpected exceptiont thrown: " + exc.ToString());
            }
            FailSafeDirectoryOperations.DeleteDirectoryInfo(dir2, false);

            //Add one year from DateTime.today.
            strLoc = "Loc_0009";

            dir2 = new DirectoryInfo(fileName);
            dir2.Create();
            iCountTestcases++;
            try
            {
                dir2.LastWriteTime = DateTime.Now.AddYears(1);
                dir2.Refresh();
                if ((dir2.LastWriteTime - DateTime.Now.AddYears(1)).Minutes > 0)
                {
                    iCountErrors++;
                    printerr(String.Format("Error_0010! Creation time cannot be correct. {0}, Now: {1}", dir2.LastWriteTime, DateTime.Now.AddYears(1)));
                }
            }
            catch (Exception exc)
            {
                iCountErrors++;
                printerr("Error_0011! Unexpected exceptiont thrown: " + exc.ToString());
            }
            FailSafeDirectoryOperations.DeleteDirectoryInfo(dir2, false);

            //Subtract one year from DateTime.today.
            strLoc = "Loc_0012";

            dir2 = new DirectoryInfo(fileName);
            dir2.Create();
            iCountTestcases++;
            try
            {
                DateTime dt = DateTime.Now.AddYears(-1);
                dir2.LastWriteTime = dt;
                if (!CompareDates(dt, dir2.LastWriteTime))
                {
                    iCountErrors++;
                    printerr("Error_0013! Creation time cannot be correct");
                }
            }
            catch (Exception exc)
            {
                iCountErrors++;
                printerr("Error_0014! Unexpected exceptiont thrown: " + exc.ToString());
            }
            FailSafeDirectoryOperations.DeleteDirectoryInfo(dir2, false);

            //Add one month from DateTime.today.
            strLoc = "Loc_0015";

            dir2 = new DirectoryInfo(fileName);
            dir2.Create();
            iCountTestcases++;
            try
            {
                dir2.LastWriteTime = DateTime.Now.AddMonths(1);
                dir2.Refresh();
                if ((dir2.LastWriteTime - DateTime.Now.AddMonths(1)).Minutes > 0)
                {
                    iCountErrors++;
                    printerr("Error_0016! Creation time cannot be correct");
                }
            }
            catch (Exception exc)
            {
                iCountErrors++;
                printerr("Error_0017! Unexpected exceptiont thrown: " + exc.ToString());
            }
            FailSafeDirectoryOperations.DeleteDirectoryInfo(dir2, false);
//.........这里部分代码省略.........
开发者ID:johnhhm,项目名称:corefx,代码行数:101,代码来源:SetLastWriteTime_dt.cs

示例8: Unzip

    private static void Unzip(ISettingsManager smng)
    {
        OutputDebug("Unzip start");

        var cancellationToken = smng.GetItem<CancellationToken>(SMNGKEY_CANCELLATION_TOKEN).Value;
        var baseDir = smng.GetItem<string>(SMNGKEY_BASE_DIR);
        var unzipWorkDir = new DirectoryInfo(Path.Combine(baseDir, "unzipWork"));
        if (unzipWorkDir.Exists) {
          Directory.Delete(unzipWorkDir.FullName, true);
        }
        unzipWorkDir.Create();

        unzipWorkDir.Refresh();
        if (!unzipWorkDir.Exists) {
          throw new Exception(string.Format("Can't create directory: {0}", unzipWorkDir.FullName));
        }
        if (unzipWorkDir.EnumerateFileSystemInfos().Any()) {
          throw new Exception(string.Format("Can't delete directory contents: {0}", unzipWorkDir.FullName));
        }

        var unzip = smng.GetItem<string>(SMNGKEY_UNZIP);
        var downloadPath = smng.GetItem<string>(SMNGKEY_DOWNLOAD_PATH);
        var startInfo = new ProcessStartInfo(unzip) {
          Arguments = string.Format("\"{0}\"", downloadPath),
          CreateNoWindow = true,
          RedirectStandardOutput = true,
          RedirectStandardError = true,
          RedirectStandardInput = true,
          UseShellExecute = false,
          WindowStyle = ProcessWindowStyle.Hidden,
          WorkingDirectory = unzipWorkDir.FullName
        };

        using (var process = new Process()) {
          process.StartInfo = startInfo;
          DataReceivedEventHandler onDataReceived = delegate(object sender, DataReceivedEventArgs e) {
        var data = e.Data;
        OutputMessage(data);
          };
          process.OutputDataReceived += onDataReceived;
          process.ErrorDataReceived += onDataReceived;
          cancellationToken.ThrowIfCancellationRequested();
          process.Start();
          process.BeginOutputReadLine();
          process.BeginErrorReadLine();
          process.WaitForExit();

          var exitCode = process.ExitCode;
          if (exitCode != 0) {
        throw new Exception(string.Format("Unzip returned error: {0}", exitCode));
          }
        }

        var unzippedDir = Path.Combine(unzipWorkDir.FullName, "chrome-win32");
        if (!Directory.Exists(unzippedDir)) {
          throw new Exception(string.Format("Unzip failed, zip: {0}, destination: {1}", downloadPath, unzippedDir));
        }

        smng.SetOrAddNewItem(SMNGKEY_UNZIPPED_DIR, unzippedDir);

        OutputDebug("Unzip end");
    }
开发者ID:hazychill,项目名称:updatechromium,代码行数:62,代码来源:updatechromium.cs

示例9: GetInfoAtPath

    /// <summary>
    /// Gets the DirectoryInfo for the file with the given filename. Checks the appropriate path based on the platform.
    /// </summary>
    /// <param name="filename">Name of file to get info on</param>
    /// <returns>DirectoryInfo for the requested file</returns>
    public static DirectoryInfo GetInfoAtPath (string filename) {

        bool persistentPath = 
        #if !UNITY_EDITOR && UNITY_IOS || UNITY_ANDROID
        true
        #else
        false
        #endif
        ;

        string dataPath = (persistentPath ? Application.persistentDataPath : Application.dataPath) + "/Resources/";
        DirectoryInfo dirData = new DirectoryInfo(dataPath);
        dirData.Refresh();
        return dirData;
    }
开发者ID:engagementgamelab,项目名称:AtStake_v2,代码行数:20,代码来源:DataManager.cs


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