Skip to main content

Posts

Showing posts from September, 2015

[Resolved] Sitecore ParseException: End of string expected at position...

Problem:  I have a line of code that uses Sitecore Fast Query to pull all items + children starting with a site item, like so: Item [] allItems = db.SelectItems( "fast:" + sitecorePath + "//*" ); Unfortunately, I would get a Sitecore parsing error at runtime: ParseException: End of string expected at position... Turns out Sitecore doesn't like hyphens ('-') in any sitecore path when using fast query, which I have a few distributor sites in a folder which contained hyphens. Solution: I create a simple method that resolves a sitecore path to be Sitecore fast query friendly:             string sitecorePath = "" ;             if (siteItem.Paths.FullPath.Contains( "-" ))             {                 String [...

SQL Server - Trim All Trailing "/" in a Table Column

Problem : Some of our redirects in our main web application were acting a little screwey. Turns out our stand-alone URL redirect app didn't play well with URLs with a trailing "/".  I needed to simply trim all trailing "/" from URLs that have them. Solution : Here's the script I created: BEGIN TRANSACTION        SELECT [url] AS ' url  with trailing "/"'        FROM    [URLRedirects] . [dbo] . [Redirects]        WHERE   RIGHT( [ url ] , 1 ) = '/'        UPDATE [Redirects]        SET     [ url ] = CASE RIGHT( [ url ] , 1 )                                          WHEN ...

Download a file directly to your "Downloads" folder without a dialog box

Problem: I built a custom web app and I wanted to download a log file directly to my downloads folder without a dialog . This app is only used by me and I specifically wanted all downloaded files in this location, no questions asked (by me, i guess) Research: I found many solutions that included a dialog box asking me where I want the file to be downloaded, but I wanted to bypass this process all together .  The key is this line of code: string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); I figured that getting the user would be hard to do, but this pretty much takes care of it. Solution: I added this to my dev tools.           protected bool SaveFileToDownloadsFolder(string fullFileName, string renamedFile)         {             string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);             stri...