Feed on
Posts
Comments

There is a way to use Powershell to search the contents of a file.  This method will not use the Windows index so it will be slow, but it does work.

get-childitem c:\users\ -filter *.txt -recurse |
    select-string -list -pattern "yourtext" | foreach {$_.Path}

Finding files

  • get-childitem: Get the children for a container.  In this example the container is a folder on the file system.
    • The first argument is the directory to search (c:\users).
    • The –filter switch is used to limit what files to search, in this example it will search files with a txt extension.
    • Process all sub-directories with the –recurse switch.
  • select-string: Find text in strings or files.
    • The –list switch stops the search within the source once the match is found.  In other words it will not waste time looking for other occurrences of the text.
    • The –pattern switch is where you specify the search text.  Regex is permitted.
  • foreach:  Iterate the resulting files.
  • $_.Path:  Output the full path for the file.

 


I needed to find a file that was created in March 2009.  The folder isn’t indexed so I created this PowerShell script to help find the files within a specified date range.

 

childitem -filter *.doc? -recurse |
    where {$_.CreationTime -gt
    [datetime]::parse("03/01/2009") -and
  $_.CreationTime -lt
    [datetime]::parse("03/31/2009") -and
        $_.length -gt 50}

 

The first line recursively finds all files with a doc or docx extension.

childitem -filter *.doc? -recurse | 

Lines 2-3 look for a file with a creation time greater than (-gt) March 1st 2009.

where {$_.CreationTime -gt
[datetime]::parse("03/01/2009") -and 

Lines 4-5 look for a file with a creation time less than (-lt)  March 31st 2009.

$_.CreationTime -lt
  [datetime]::parse("03/31/2009") -and 

And the final line looks for files larger that 50 bytes.

$_.length -gt 50}

In my opinion writing about the blogging and blogging software makes for dull reading.   The only people that are interested are fellow bloggers.   Having said that I do want to write about changing my blog server however because it is likely to affect incoming links.

This site has been running for over five years on the .Text blogging platform.  .Text was abandoned years ago and has suffered from lack of attention.  I’ve delayed moving to new software because I knew it would take a lot of time to get it done correctly.  This month we moved all of our websites to a new server so it was time, Anyway the move is done and the site is now happily running on WordPress.

I have tried to anticipate any changes to post URLs and have URL rewriting enabled. 


My New WPF blog and site

2007 is going to the year of WPF for me.   I’ve got a lot of projects pending, I’ll tell you more about them as I get the details worked out.   But  I can tell you this….

I started a new blog at wpfwonderland.wordpress.com that’s dedicated to WPF topics.  I’ll have a companion website up and running sometime this month too.(www.wpfwonderland.com )

Please check it out.  I’m really excited about WPF.  Can’t wait to talk to you about all the cool bits.

Walt

Hooray! Microsoft released the service packs for Visual Studio today.  These are a MUST INSTALL for anyone using VS.  There are plenty of bug fixes.  The two that I’m most excited about are the Visual Basic background compiler fix and the performance fix for compiling large projects.  Both of these issues have slowed my daily development consistently during the last year.

If you are an ASP.NET developer you’ll be happy that the Web Deployment and Web Application projects are now included.

Microsoft has added some interesting new features in the SP too.

  • Multicore support for profiling
  • Multicore support for code gen
  • Team Server performance improvements
  • See the Microsoft website for more details

There are several version of the SP. Pick the one that matches your version of Visual Studio.

Seriously, if you are using Visual Studio 2005 you should install this SP as soon as possible.

 

Would you like a free copy of Windows Vista?  You have to spend a few hours looking at some webcasts and fill out some information.  Doesn’t seem like much work for $300 worth of software.

Wait, there’s more.  A free copy of Office 2007 Pro ($500) if you watch some marketing videos for Office.  So far I haven’t seen the catch, unless it’s a fake site.

I don’t understand the reasoning behind the offer or the odd marketing videos on YouTube.com but do you care?  Nah, it free.  If you haven’t tried Vista you really should.  This just makes it easier.  

Offer expires the end of February 2007

Legal description below

  • The Power Together Campaign consists of two (2) offers, the Windows Vista Business Offer and the Microsoft Office Professional 2007 Offer, and is open only to legal residents of the 50 United States (includes District of Columbia) 18 years of age or older.
  • You are not eligible to receive these offers if you or your employer is a participant in the Microsoft Partner Program or the Microsoft Developer Network.
  • To be eligible to receive Windows Vista Business, you must register at www.powertogether.com and participate in at least three (3) qualifying web casts and/or virtual lab sessions within 30 days of registration.
  • To be eligible to receive Microsoft Office Professional 2007, you must register at www.powertogether.com and participate in at least three (3) qualifying web casts and/or virtual lab sessions within 30 days of registration.
  • In order to register at www.powertogether.com, you may be asked to provide personal information including name, telephone, and address. All personal information gathered during registration will be subject to Microsoft’s privacy policy.
  • Limit one gift per person per Offer.
  • These offers are non-transferable.
  • These offers expire on February 28, 2007, or while supplies last, and are not redeemable for cash.
  • Taxes, if any, are the sole responsibility of the recipient. If you are eligible for and register to receive both gifts, you must complete a W-9 (Request for Taxpayer Identification Number and Certification) form prior to receipt of the second gift.
  • Any gift returned as non-deliverable will not be re-sent. Please allow 6 – 8 weeks for shipment of your gift(s).

 

  • Government Customers: Microsoft intends that use of the services and products offered as part of this promotion comply with applicable federal, state, provincial, and local government gift and ethics rules.
  • If you are a government employee (including an employee of a public education institution), these services and products may be used for evaluation purposes only, solely for the benefit of your agency or institution, and not for the personal use or benefit of any individual.
  • You should consult with your agency or institution counsel or ethics officer prior to use of these services or products. You may return the products to Microsoft at its expense.

I installed Office 2007 a couple weeks ago.  Sorry, I’m not going to call it by its new name (2007 Office System).  That name seems backwards to me.

If you are using Office 2007 you’ve undoubtedly said “where did they put that?’ a time or two. Tech-Net has a nice overview of all the changes you’ll need to learn. 

We all have our strengths and weaknesses when it comes to developing software.   It’s widely known, for instance, that most developers are crummy at UI design or making their application look good. Some programmers, on the other hand, are really good at data structures and normalizing data for relational databases.  I worked on a project this year with a fellow who could instantly see the way complex data should be represented in the data model.   I have to think about it much longer, and even then I’m sometimes not sure if I’ve picked the best approach.  Guess which one of us did most of the database design work?

Other peoples work

Looking at another programmers source code can be educational.  Reading an existing database schema can also be helpful.  Barry Williams has a huge library of free database schemas for you to look at.  Over 300 sample databases in all.

Examples

  • Payrolls
  • Permits and Licenses
  • Car Dealership
  • Real Estate Rentals
  • Global Law Firm
  • City Tourist Guide
  • Data Warehouses
  • Law Enforcement – Case Management
  • Landscape Gardening
  • You need a picture or two for your next project mock-up. 
  • You need it now.
  • You don’t want to pay a lot, it’s only a mock-up!

There are several websites that will sell you a nice, high-resolution image for cheap.   Today’s find:

http://www.dreamstime.com/

Web licensing for as low as $0.74 per picture.   They also give you seven free pictures every week.

The new ASP.NET 2.0 TreeView control is pretty handy.  It can function as a normal treeview – where you can add/remove treenodes to the nodes collection. It can also serve as a site navigation tree.  In this mode each node on the tree becomes a hyperlink to another webpage.  The hyperlink gets its Href from the treenodes NavigationUrl property which in turn gets its Url from the web.sitemap file.

Today I finally solved one of the annoying dilemmas that crops up when using the Treeview.

The problem

A treenode can be selected or expanded.  Selecting the node causes the SelectedNodeChange event to fire if the Treeview is configured correctly.  Clicking the + icon on a node causes the TreeNodeExpanded event to fire.  The selected event will not fire if the node is in Navigation mode.    This behavior makes sense most of the time.  The node is acting  as a navigation link  – it causes the browser to take you to a new page which means there is no postback.  Your are going to a new page, without returning to the server first.

If the node has its NavigationUrl property set to an empty string, the node is in Selection mode.  If the NavigationUrl is a non-zero length string ,the node is in Navigation mode.

For our project I wanted the children nodes to expand whenever the user selects a parent node.  Yes, the user can click the + symbol to expand it,  but our testing showed that many users expect the node to expand by clicking the node text instead. Since the nodes are in Navigation mode I couldn’t  put the code in the SelectedNodeChanged event.

My solution?  Use the TreeNodeDatabound event to examine each node as it is being bound to the tree.  If the current page URL matches the treenode NavigationUrl I expand all the of the current nodes children.  It solves my problem.  It still doesn’t cause the SelectedNodeChanged to fire so it may not solve all your troubles. At least it’s a start.

Protected Sub treeMainMenu_TreeNodeDataBound _
           (ByVal sender As Object, _ 
ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) _
Handles treeMainMenu.TreeNodeDataBound
‘ other binding code here…
If Request.Url.PathAndQuery = e.Node.NavigateUrl Then
e.Node.ExpandAll()
End If
End Sub

 

Comments

7/7/2006 9:04 AM EAI

Your code helped me indirectly. Thanks a lot.

7/8/2006 1:20 PM Martin

Thanks you code also helped me indirectly.
Saved quite some time.

Selection vs Navigation 7/19/2006 10:07 AM Alejandro Cifuentes

Thank you very much for your tips. I have made a change to your code. I need that a navigation node shows as an hyperlink, to expand the lower ones, so i modified the code to:
If e.Node.NavigateUrl = "" Then
e.Node.SelectAction = TreeNodeSelectAction.Expand
End If
Best regards,
Alejandro.

8/17/2006 11:10 AM Andy

I used you code (thanks alot) and got this working in a demo project, but the more I played around with firing different events ans setting databindings … eventually it stopped working. No I cannot get it to work again. The TreeNodeDataBound event fires, and the call to expandAll() runs, but it does not expand. There seems to be a bunch of different properties in this control that force other properties to change to thier default, irrespective of what you set.
For example setting populateondemand in the databindings
like
<DataBindings>
<asp:TreeNodeBinding PopulateOnDemand=true
TextField="Title" NavigateUrlField="URL" />
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/CustSiteMap.asp)
or setting it in code in the TreeNodeDataBound event does not work.. must be overriden by another setting.
Anyone else experience this.

8/17/2006 11:31 AM Andy

Here is my code which no longer works. Where the TreeNodeDataBound event fires, and the call to expandAll() runs, but it does not expand.
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" ExpandDepth="1"
OnTreeNodeDataBound="TreeView1_TreeNodeDataBound">
</asp:TreeView>
protected void TreeView1_TreeNodeDataBound(object sender, System.Web.UI.WebControls.TreeNodeEventArgs e) {
if (Request.Url.PathAndQuery == e.Node.NavigateUrl) e.Node.ExpandAll();
}

8/17/2006 11:39 AM Andy

ok I remember I need PopulateNodesFromClient="false" in order to get the click on the text to navigate and expand.
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" ExpandDepth="1"
OnTreeNodeDataBound="TreeView1_TreeNodeDataBound" PopulateNodesFromClient="false">
</asp:TreeView>

8/18/2006 10:42 AM Wendy

Thank You!! I have been searching for 2 days and have found tons of code but nothing that did exactly what I needed it to. This was just what I was looking for. Thanks a ton…

Older Posts »