Sponsored Links

Could not execute CVTRES.EXE

Today I started woking on a windows application at home and I was very annoyed by the error I was getting whenever I tried to debug/build the application that said: “Could not execute CVTRES.EXE”

Tried lots of things like giving full rights to “everyone”  on the debug folder and some other silly things, untill I found [...]

How to use an OR in a query in EntitySpaces?

It’s simple, yet not very obvious. All you have to do is to change the normal behavior of the commas you use in the Where function to act as an OR. You’d do it like this:-

ObjES.Query.es.DefaultConjunction = esConjunction.Or;
ObjES.Query.Where(<<Go ahead with using the commas that usually defaults to an AND conjunction>>);

oh and I almost forgot to [...]

How to remove ReadOnly Attribute from a file?

Hello friends,

Here’s a nice little piece of code you can use to change file attributes of a particular file, its particularly useful when you’re trying to delete a read only file.

string savedCardFilePath = “My absolute file path”;

if (File.Exists(savedCardFilePath))
{
/*
* Remove readonly attribute off of the file if it exists before execution
*
**/
if(File.GetAttributes(savedCardFilePath) == FileAttributes.ReadOnly)
File.SetAttributes(savedCardFilePath, FileAttributes.Normal);
File.Delete(savedCardFilePath);
}

How to use OrderBy() for multiple columns in EntitySpaces?

You can pass multiple columns in like this:-

collection.Query.OrderBy(collection.Query.ProductID.Descending, collection.Query.CategoryID.Ascending)

How to manipulate Session in Http Handlers

There is a common issue that you can’t manipulate session objects in http handlers, the files with ASHX extension Well normally you can read the contents in the session via context.Session but you can add/remove/modify that in there. So how do you do this:

The answer is simple: Just implement the IRequiresSessionState interface. It [...]

How to get the file name from a full file path?

If you have a full file path like D:\My Documents\myimg.jpg and you want to get just the file name myimg.jpg, you can get it with the help of the Path class in this fashion:-

In C#

string filename = Path.GetFileName(“D:\My Documents\myimg.jpg“);
In VB .NET

Dim fileName as String = Path.GetFIleName(“D:\My Documents\myimg.jpg”)

How to generate Random numbers in .NET

Actually these are not exactly ‘true’ random numbers. These are actually pseudo-random numbers, which means that they give you an illusion that they’re being generated randomly.

It’s very simple: There’s a class called System.Random. and the rest is as simple as this:-

Random r = new Random(0);
int num = r.Next(0,999999);

in VB .NET

dim r as Random = new [...]

How to make a file download on button click?

Ever wonder how you could put in the functionality of downloading a file when the user clicks the button? Well here’s how I did it. The technique is to send the file to the browser via response and put the content type to application/pdf. Without putting in any further delays, here’s the code.

/// <summary>
/// opens [...]

Generating PDF document in .NET using iTextSharp Library

well, it was just yesterday that I was looking into converting html to pdf programmatically in .NET 2.0. After some googling, I came up to the iTextSharp library at SourceForge.

Just built an application to test run this iTextSharp library. so here’s the code for the “Hello world” application.

private void HelloWorldPdf()
{
try
{
iTextSharp.text.Document oDoc = new iTextSharp.text.Document();
PdfWriter.GetInstance(oDoc, new [...]

How to Add Shaded Rows to ListView's Details View

Sometimes it can be challenging to read the Details view in a ListView, especially if the rows are long. This article shows how to add shading to every second row to make a ListView easier to read.

As you may know, you can alter the appearance of individual ListViewItem’s such as the Font and BackColor. But [...]