jcTree Documentation In this post I will show you how to use jcTree.exe to create a Javascript enabled tree from your command line. First up lets check out the command help as shown below [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f393831386583263/] Download this Utility from this URL http://jaspreetchahal.org/jctree-a-c-tool-to-create-jquery-javascript-enabled-folder-or-directory-tree-and-output-to-html-file/ I am not going to explain what each switch does but I am going to narrate couple of use cases Create a tree from Directory structure and save it to index.html under a given target folder Create a tree from Directory structure and save it to index.html under a given target folder with TXT files only and apply classic jsTree theme to it with verbose mode. Test Directory Structure C:\cutils\JCRSBackup.exe C:\cutils\License.txt C:\cutils\print.txt C:\cutils\Readme.txt C:\cutils\RackSpaceWindowsClient C:\cutils\RackSpaceWindowsClient\License.txt Scenario 1 Assuming the above directory structure exists lets create a tree for above directory structure and store it in c:\demo folder. One good thing about this Util is that if the target folder does not exist it will create it automatically The command [crayon-648333f393835854480498/] [crayon-648333f393836023823005/] When you run the above command "demo" folder will be created with index.html inside it. Notice that jsTree will also be copied to the destination folder. This is a requirement. Without it your tree will only be a unordered HTML list. Lets check out the browser output So we get nice tree and each node is a link to the file itself. From here on you can do whatever you like with your newly created file. Scenario 2 Assuming the directory structure is the same as in Scenario 1 use the command below The command [crayon-648333f393837571381925/] [crayon-648333f393838660593599/] When you run the above command "demo" folder will … [Read more...]
c# how to create XML without XML tag using XMLDocument and XMLWriter
[sam_ad id="48" codes="true"]Hi Guys, I had this problem where I just wanted to create a XML file without a XML tag. Frankly I was just creating a HTML snippet which I needed to embed in some other file. I am not going to show you all that code but instead I will show you the important bits. Below is the code that you should be looking for to create a XML file without XML tag. So we are using XMLDocument class to create a XML document. I am just using file name to include .html because that fit my scenario. Feel free to change it to any other extension. [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f393ddd192101799/] Above code will produce the output file with contents below [crayon-648333f393de0468470622/] [crayon-648333f393de1434173020/] Important thing in the above code is utilizing XmlWriterSettings class and putting OmitXmlDeclaration property to false. Make sure that you also set ConformanceLevel to Fragment, by default it is set to Document and when XMLWriter is outputting a document it always will include XML tag. Lets omit XmlWriterSettings from the above code to make it equivalent to the code below [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f393de2541040576/] Above code will now output file called somefile.html with following contents [crayon-648333f393de3576163480/] [crayon-648333f393de4155403721/] I hope this helps … [Read more...]
c# How to copy directory and subdirectories files to new location programmatically
Well when I started writing this function I had no Idea what to expect. I checked MSDN and I couldn't find a function that can do this for me. I could be wrong because at midnight you can't expect your brain to be working at peak :) Alright so here is what I came up with. I will show you how you can use this function after defining the function [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f393fbe893297747/] Lets see how we can use this function [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f393fc1773986581/] You can pass optional param values as per requirement. Above is an approach and you can off course always do better. If you would like to add something to this post please do so via leaving your comments. I hope this helps Cheers … [Read more...]
c# handle double quotes in string
This stuff is really simple and I was almost convinced that I should not be writing about this. But silly me that today I made a mistake when defining a string with double quotes and then I thought Oh well! lets write about this. Ok Lets see how do you define a Double quotes in a String. Below is an example showing how this is done. [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f394211416599816/] As you see that in a string you will need 2 Double quotes to make a quote a valid char. You can also do something stated below [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f394214667689095/] Lets see an example with multiline string [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f394215670061762/] [crayon-648333f394216108390280/] I hope this helps … [Read more...]
rscfpush.exe – A RackSpace Cloud Files Command Line Uploader
Hi Guys, Not maintained as of Jan 2013. May still work. Lately I have been doing few things in relations to Rackspace Cloud files. I think I can't have enough of it. But my sources tell me that I will burn my A** if I keep on dong that. So I did not listen to my sources and I end up developing Rackspace Cloud files Uploader util called rscfpush.exe It is handy Util that you can has as a part of your Cloud Command Line treasure. Did I went too far in calling utils that I write treasures :). I think Yeah! They are Ok whatever I develop but I always want more :) Alright You must be thinking what sort of jerk I am but that Ok. Lets get back to rscfpush.exe Some usage scenarios can be found here http://jaspreetchahal.org/documentation-rscfpush-exe-a-rackspace-cloud-files-uploader-for-lite-files But overall speaking here is what you can do with this util [geshi lang="ini" nums="1" target="_self" ] [crayon-648333f39433d709084825/] Support me Please either buy a paid version of this software as a token of you support for only $19.99 or you can choose to donate. The only thing that is different in Paid version is that you are able to use these switches -ccine Create container if it does not exist -mcpub Make container public There are no hard and fast rules that states that you will have to buy the Paid version. It will sound weird but you can have PAID version for FREE :) Just contact me and tell me that you don't have 19 odd bucks to support and you get the download link. Its as simple as that. ;-) Or consider donating Disclaimer THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE … [Read more...]
c# Get all files from Directory and sub directories
Hi Guys, Today I will show you how you can utilize .NET's inbuilt API function to get list of all files under a directory and all its subdirectories. First lets get files from a given Directory Lets assume that the target directory structure is one show below. C:\cutils\License.txt C:\cutils\print.exe C:\cutils\Readme.txt C:\cutils\RackSpaceWindowsClient C:\cutils\RackSpaceWindowsClient\License.txt If you want to get all files under c:\cutils you can do so using the code below [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f394532847733140/] What if you want to get files in the subdirectories of c:\utils Get files from a given Directory and its subdirectories [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f394535068805145/] In above code passing SearchOption.AllDirectories as third param to Directory.GetFiles() is the key. Lets talk about second param where I passes "*.*" Second param is a search pattern which will be applied as a filter. Ok lets say if you want to print files that has extension txt you can do so by passing in *.txt as a second param value. Code below shows that [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f394536379228973/] As you see the above result does not include c:\cutils\print.exe I hope this post helped you. Cheers … [Read more...]
c# check if path exists
Hi guys, So many a times we have this situation where we know user can input path as a directory or a path to file itself. Now in those circumstances we want to check if the path to directory or file is valid or not. Generally you can do it in several ways and make things as complex as possible. Below is a function that I use to find out if supplied path Exists or not [crayon-648333f394670142972513/] You can also use File.Exists to check if the file exists [crayon-648333f394673178456134/] Or [crayon-648333f394674542288735/] to check if the path is a directory. You will be interested in reading this post written by me to find out if the supplied path is a path to Directory or path to File. Read it here http://jaspreetchahal.org/c-check-if-path-a-directory-or-file/ I hope this helps. … [Read more...]
c# check if path a Directory or File [solved]
G'Day Fellas, I had this problem where I had to check whether the supplied path is a Path to File or it is a Directory. There are few ways of doing this. e.g. using File.Exists() Directory.Exists() functions. But then I thought there would definitely something else that could improve the code. There is nothing wrong with the above approach but I then found out that File Class comes with a method called GetAttributes Here is how we use it [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f394760231016161/] You can put it in any of your Util class function to re-use above code. I hope this helps … [Read more...]
c# how to place caret/cursor position at start or end of textbox
This question has been addressed by many but I will give you an insight on this too Say you textbox is named: txtCaret Now to move the Caret position to the end of text in txtCaret simple use the code below [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f394912850431577/] And If you like the Caret position at the beginning of the text Box use the following code [crayon-648333f394913145478353/] If you would like to select all text with txtCaret use the code below [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f394914737697473/] So you can do pretty much select any given string in a textbox if you really know what your selection will be. I hope this helps … [Read more...]
c# replace a keystroke character with other key
How do you replace a character with other while "say" you are typing in a textbox or text area. There are couple of ways to do it. Lets consider an example. So say While I am typing a browser URL I always want people to enter '/' instead of '\' I will create an Event for Keydown for your textbox or textarea So lets say your textbox' ID is txtText [Geshi] [crayon-648333f3949e2211724784/] [/Geshi] In the sample above most important bit is to Suppress the Key press thus we are using e.SuppressKeyPress = true Other way is pretty much the same but you will see a little flicker when replacement occurs so I prefer the above technique always but its worth to show you any way because the technique below will actually replace all source replaceable characters with the new one [geshi lang="csharp" nums="1" target="_self" ] [crayon-648333f3949e4533391808/] So this is how you can manipulate Keystokes and do whatever with them. Even though I consider it as not so user friendly but there can be many other use cases where this is acceptable, say for example only allow numerics in a text field etc I hope this helps … [Read more...]
Recent Comments