惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Hacker News: Front Page
博客园 - 【当耐特】
量子位
博客园 - 聂微东
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Register - Security
The Register - Security
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
Jina AI
Jina AI
The Cloudflare Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AWS News Blog
AWS News Blog
L
LINUX DO - 最新话题
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Schneier on Security
Stack Overflow Blog
Stack Overflow Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Engineering at Meta
Engineering at Meta
W
WeLiveSecurity
博客园 - 三生石上(FineUI控件)
Security Archives - TechRepublic
Security Archives - TechRepublic
Hugging Face - Blog
Hugging Face - Blog
T
Troy Hunt's Blog
C
CERT Recently Published Vulnerability Notes
N
News and Events Feed by Topic
S
SegmentFault 最新的问题
美团技术团队
C
CXSECURITY Database RSS Feed - CXSecurity.com
人人都是产品经理
人人都是产品经理
SecWiki News
SecWiki News
N
News and Events Feed by Topic
C
Check Point Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
宝玉的分享
宝玉的分享
Schneier on Security
Schneier on Security
阮一峰的网络日志
阮一峰的网络日志
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
J
Java Code Geeks

博客园 - gyhanonline

Function Point in Vbscript Window API in QTP Simulate click event using widows API. Static Constructor A Go Set program A Go Set program About Inherit Code for Inter-process communicate Integrity Level Test for publish blog by word 2007 托管为什么安全 The usage of intellisense in Vs .net 2005 我的面试(七) 关于singlton的一些问题 我的面试(五) 我的面试(四)补充1 我的面试(四) 我的面试(三) 我的面试(二)
我的面试(六)
gyhanonline · 2007-10-01 · via 博客园 - gyhanonline

      9月25日,下着雨又去面试了,这日子过得真是辛苦。是个美国公司,韩国、印度都有网点。中国这个办事处刚建。这面试到也简单。填一份表格(全英文)。做了一套题。比我在北京面试的那些骚动公司的题简单多了,都是些原则性的题,还有就是对于你项目经历的描述。没想到还有这么考的。又是英语又是韩语的以为会经受什么考验,呃。没想到被mm带到一个madam的办公室,开始考英文。当然了上来是一些情况介绍。工资给的不高。然后是他们公司的简介,让俺念又让俺译。幸亏没让俺自己创造几句鸟语。磕磕绊绊总算过关。(居然问我为什么不会开车,俺的神呀!你就给俺那几k,是车开俺还是俺开车呀!)
     大头儿在后边,正式考试原来是发个项目回家做。第一次遇到这样公司。大老美就是新鲜。不过正和吾意。俺这离了机器不会编程的傻子,这次终于也能畅快一把了。
     题目还行,不难但能见点儿功力。
     大概需求是做一个类似资源管理器一样的东东。将指定folder和他所有的subfolders全部列出到一个listView中,显示为:“foldername,size,path”,当计算时按stop就停下来。
     这个题有几个考点俺觉的还行:
     1。算folders的size;(这个考了个第归的东东)

      /// <summary>
        
/// calculate folder size of Folder specified and its subfolders
        
/// They are listed in the list view(lvFolders).
        
/// Each row  have 3 columns - Folder Name, Size (Bytes), Full Path Name
        
/// </summary>
        
/// <param name="rootDirectory">source path</param>
        
/// <returns>folder size</returns>

        private long GetFolderList(string rootDirectory)
        
{
            
long size = 0;
            
foreach (string tempDirectiory in Directory.GetDirectories(rootDirectory))
            
{
                size 
+= GetFolderList(tempDirectiory);
            }

            
foreach (string tempFile in Directory.GetFiles(rootDirectory))
            
{
                size 
+= new FileInfo(tempFile).Length;
            }

            
string[] oneFolderInfo = new string[3];
            oneFolderInfo[
0= Path.GetFileName(rootDirectory);
            oneFolderInfo[
1= size.ToString("###,###,##0");
            oneFolderInfo[
2= rootDirectory;
            
this.Invoke(new DealWithControlDelegate(DealWithControl), new ListViewItem(oneFolderInfo));//insert one folder infomation into the listView.
            return size;

        }

      2.按stop停止。(多线程问题。其实这个东东2005以后就有一个什么什么backprocess的组件了,但是他是2003,那就用Thread也不难,有个线程间数据同步问题用invoke这个方法也就能搞定了。)

            calculateProcThread = new Thread(new ThreadStart(CalculateProcessMethod));
            
this.SetControlState(ControlStatement.beforeCalculate);
            calculateProcThread.Start();

就这new一个,然后start就行了。别忘了kill了它:

            if(this.calculateProcThread.IsAlive)
                
this.calculateProcThread.Abort();

     3.listViewa按列排序(这个没啥,msdn上有例子,实现个ICompare就行了):

        public class ListviewItemComparer : IComparer
        
{
            
private int col;

            
private SortOrder sorting = SortOrder.Ascending;

            
public SortOrder Sorting
            
{
                
set
                
{
                    sorting 
= value;
                }

                
get
                
{
                    
return sorting;
                }

            }


            
public ListviewItemComparer()
            
{
                col 
= 0;
            }


            
public ListviewItemComparer(int column)
            
{
                col 
= column;
            }


            
public int Compare(object x, object y)
            
{
                
if (col != 1)
                
{
                    
if (sorting == SortOrder.Ascending)
                        
return String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
                    
else
                        
return String.Compare(((ListViewItem)y).SubItems[col].Text, ((ListViewItem)x).SubItems[col].Text);
                }

                
else
                
{
                    
if (sorting == SortOrder.Ascending)
                        
return long.Parse(((ListViewItem)x).SubItems[col].Text, System.Globalization.NumberStyles.Any) > long.Parse(((ListViewItem)y).SubItems[col].Text, System.Globalization.NumberStyles.Any) ? 1 : -1;
                    
else
                        
return long.Parse(((ListViewItem)x).SubItems[col].Text, System.Globalization.NumberStyles.Any) < long.Parse(((ListViewItem)y).SubItems[col].Text, System.Globalization.NumberStyles.Any) ? 1 : -1;

                }


            }


        }

ok了,这个小玩印儿就这样被我搞定了哈。
完整项目下载