????? ????? ???? ??? ??? ???? ?????? ??????? ???????? Visual C#

?????? ????????? ?????? ?????????
???? ???????: 315460 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ?????? ???? ????? ??? ????? ????? ????? ?? ???? ?????? ??????? ???????.

?? ???? .NET ??? ?? ????? ???? ?????? ????? ???? ???? ????????? ?????? ?????? ???? ??? ??????.

???????


???? ??????? ??????? ??????? ?????? ??? ????? ?????? ???????? ?????? ? ??? ??????? ????????:
  • Microsoft Visual Studio .NET ?? Microsoft Visual Studio 2005
????? ??? ??????? ??? ??????? ??? ???????? ???????:
  • Visual C# ??? ???????

????? Visual C# ????? ???? ?????? ???? ???? ???????

  1. ??? ????? Microsoft Visual Studio .NET ?? Microsoft Visual Studio 2005.
  2. ????? ????? ??????? Visual C# ?? Windows ???? ???? PoolDemo.
  3. ?????? ???? ??????? ?????? ???? ???? ?? ??? ???????. ????? ????????? ????? ?????? ?? ?? button1.
  4. ???? ??? ?????? ?????? ??? ??????? ?? ???? ??? ??? ????????? ????????.
  5. ??? ??????? ???????? ??????? ??? ??????? ???????? ???????? ???? ??? ????? ????? ??? PoolDemo:
    using System.Threading;
    					
  6. ??????? ??? ????? ????? "?????" ?? ???? ????? ??????? ??? button1. ?? ???? ???????? ???????? ??????? ?? ????? ??????? button1_Click:
    private void button1_Click(object sender, System.EventArgs e)
    {
    	WaitCallback wcb = new WaitCallback(GetSysDirSize);
    	try
    	{
    		ThreadPool.QueueUserWorkItem(wcb);
    		MessageBox.Show("The work item has been placed on the queue");
    	}
    	catch (Exception ex)
    	{
    		MessageBox.Show("Error: " + ex.Message);
    	}
    }
    					
  7. ?? ???? ???????? ???????? ??????? ???? ?? ????? Form1. ????? GetSysDirSize ????? ????? ???????? ???????? ???? ??? ??????? ?? ???? ??????. ????????? GetSysDirSize ????? ??? ???? DirSize ?????? ??????? ????????.

    ??????: ??? ?????? ?? ?????? ??? ????? ??????.
    private void GetSysDirSize(object state)
    {
    	long total_length = DirSize(Environment.SystemDirectory);
    	this.Text = total_length.ToString();
    }
    
    private long DirSize(string path)
    {
    	long sz = 0;
    	System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(path);
    	
    	// List files.
    	foreach(System.IO.FileInfo f in d.GetFiles())
    	{
    		sz += f.Length;
    	}
    
    	// Recurse into directories.
    	foreach(System.IO.DirectoryInfo dx in d.GetDirectories())
    	{
    		sz += DirSize(dx.FullName);
    	}
    
    	return sz;
    }
    					

?????? ?? ?????

  1. ???? CTRL + F5 ?????? ???????.
  2. ??? ???? "???????" ? ???? ??? ????. ??? ???? ???? ????? ?? ??? ???? ????? ?? ????? ????????? ???? ??? ????? ?????? ???? ??????? ??????? ??? ??????? ???????. ??? ??? ??? ????? ???????? ?? ???? ?????? ??? ???? ????? ?? ??????? ??????? ???????. ????? ??? ??????? ??? ???? ????????? ???? ??????? ?? ???? ??????. ???? ?????? ????? ??????? ???? ??? ???? ????? ?? ???? ?????? ???????.

???????

???? ???????: 315460 - ????? ??? ??????: 20/?? ??????/1427 - ??????: 2.3
????? ???
  • Microsoft Visual C# 2005 Express Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
????? ??????: 
kbmt kbhowtomaster kbsample kbthread KB315460 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????315460

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com