Links
Calendar
<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567
Blogroll
Site statistics
Keywords
rezashirazi , posted on 15. November 2008, 13:46

You can create a function for removing html tags from html string. here it is:

    Protected Function removeHTML(ByVal html As String) As String
        If String.IsNullOrEmpty(html) Then
            Return ""
        Else
            Return System.Text.RegularExpressions.Regex.Replace(html, "<[^>]*>", String.Empty)
        End If
    End Function

 Happy Programming Smile

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

The Reflector download is one zip file containing configuration files and a readme file, along with an executable. Once you run the program, base .NET assemblies are loaded; this includes mscorlib, System, System.Data, System.Drawing, System.Web, System.Windows.Forms, and System.Xml.

Reflector provides a File drop-down menu to load and process your assemblies. A Reflector option (which is available from the Tools menu) allows you to choose the .NET Framework version used by the tool. Decompiled assemblies are presented in a tree format. The user clicks a plus sign (+) alongside each assembly to expand and view its contents.

Reflector allows you to easily examine a class and its methods, as well as disassemble a class, by double-clicking it or using the Tools menu. The source code appears in a pane on the right side of the interface.

Analyze is another option that is available via the Tools menu. It processes the code and generates results detailing what assemblies it uses, along with the assemblies that use it.

Reflector supports C#, VB, Intermediate Language (IL), Delphi, C++, and Chrome. You can decompile an assembly and view its source in one of these languages.

An interesting byproduct of the multiple language support is the ability to easily translate from one language to another; that is, if you develop an application using C#, you can easily convert it to VB by loading its assembly in Reflector and viewing its source in VB.

Another great feature of Reflector is its extensibility, thus it is easy to create add-ons. The CodePlex site provides an excellent list of available .NET Reflector add-ins. A good example is CodeSearch, which allows you to easily search for text or regular expressions within disassembled code.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Hi ,

 I find a solution for adding websites to IIS with asp.net, this is very amazing! the first step is adding Microsoft.Web.Administration.dll to your project's refrences, it is at "windir\system32\inetsrv\" folder.

 Here is the code:

C# version:

using System;

using Microsoft.Web.Administration;

class Program

{

static void Main(string[] args)

{

ServerManager mgr =
new ServerManager();

mgr.Sites.Add("MyWebSite", "http", "198.1.1.0:80:",

@"d:\MyWebSiteRootWebAppRootVirDir");

mgr.CommitChanges();

}

}

 VB.NET version:

Imports Microsoft.VisualBasic

Imports Microsoft.Web.Administration

Imports System.Configuration

Public Class clsCreateWebsite

Public Function createWebsite(ByVal websiteName As String, ByVal domainName As String, ByVal physicalPath As String) As Boolean

Dim IIS_manager As New ServerManager

Try

IIS_manager.Sites.Add(websiteName, "http", "*:80:" + domainName, physicalPath) IIS_manager.CommitChanges()

Return True

Catch ex As Exception

Return False

Finally

IIS_manager = Nothing

End Try

End Function

End Class

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
What Regular Expression?
A regular expression is a pattern that can match various text strings, used for validations.

Where and when to use Regular Expression?
It can be used in the programming languages which supports or has regular expression class as in built or it supports third party regular expression libraries.

Regular expressions can be used to valid different type of data without increase the code with if and case conditions. A number of if conditions can be omitted with single line of regular expression checking.

Benefits of Regular Expression:
The following are benefits (not all included) of use of Regular Expression.
a) # line of code can be reduced.
b) Speed Coding.
c) Easy maintenance (you don’t need to change if validation criteria changes, just check the regular expression string).
d) Easy to understand (you don’t need to understand the programmer logic on large if statements and case statements).

Elements of Regular Expression:
Here are the basic elements of regular expression characters/literals, which can be used to build big regular expressions:

^ ---->Start of a string.
$ ---->End of a string.
. ----> Any character (except \n newline)
{...}----> Explicit quantifier notation.
[...] ---->Explicit set of characters to match.
(...) ---->Logical grouping of part of an expression.
* ---->0 or more of previous expression.
+ ---->1 or more of previous expression.
? ---->0 or 1 of previous expression; also forces minimal matching when an expression might match several strings within a search string.
\ ---->Preceding one of the above, it makes it a literal instead of a special character. Preceding a special matching character, see below.
\w ----> matches any word character, equivalent to [a-zA-Z0-9]
\W ----> matches any non word character, equivalent to [^a-zA-Z0-9].
\s ----> matches any white space character, equivalent to [\f\n\r\v]
\S----> matches any non-white space characters, equivalent to [^\f\n\r\v]
\d ----> matches any decimal digits, equivalent to [0-9]
\D----> matches any non-digit characters, equivalent to [^0-9]

\a ----> Matches a bell (alarm) \u0007.
\b ----> Matches a backspace \u0008 if in a [] character class; otherwise, see the note following this table.
\t ---->Matches a tab \u0009.
\r ---->Matches a carriage return \u000D.
\v ---->Matches a vertical tab \u000B.
\f ---->Matches a form feed \u000C.
\n ---->Matches a new line \u000A.
\e ---->Matches an escape \u001B

$number ----> Substitutes the last substring matched by group number number (decimal).
${name} ----> Substitutes the last substring matched by a (? ) group.
$$ ----> Substitutes a single "$" literal.
$& ----> Substitutes a copy of the entire match itself.
$` ----> Substitutes all the text of the input string before the match.
$' ----> Substitutes all the text of the input string after the match.
$+ ----> Substitutes the last group captured.
$_ ----> Substitutes the entire input string.

(?(expression)yes|no) ----> Matches yes part if expression matches and no part will be ommited.


Simple Example:
Let us start with small example, taking integer values:
When we are talking about integer, it always has fixed series, i.e. 0 to 9 and we will use the same to write this regular expression in steps.

a) Regular expression starts with “^”
b) As we are using set of characters to be validated, we can use [].
c) So the expression will become “^[1234567890]”
d) As the series is continues we can go for “-“ which gives us to reduce the length of the expression. It becomes “^[0-9]”
e) This will work only for one digit and to make it to work for n number of digits, we can use “*”, now expression becomes “^[0-9]*”
f) As with the starting ending of the expression should be done with “$”, so the final expression becomes “^[0-9]*$”

Note: Double quotes are not part of expression; I used it just to differentiate between the sentences.

Is this the way you need to write:
This is one of the way you can write regular expression and depending on the requirements and personal expertise, regular expression could be compressed much shorter, for example above regular expression could be reduced as.

a) Regular expression starts with “^”
b) As we are checking for the digits, there is a special character to check for digits “\d”
c) And digits can follow digits , we use “*”
d) As expression ends with “$”, the final regular expression will become
"^\d*$”

Digits can be validated with different ways of regular expressions:

1) ^[1234567890]*$
2) ^[0-9]*$
3) ^\d*$

Which one to choose?
Every one of above expressions will work in the same way, choose the way you are comfort, it is always recommended to have a smaller and self expressive and understandable, as these will effect when you write big regular expression.

Example on exclude options:
There are many situation which demands us to exclude only certain portion or certain characters,
Eg: a) Take all alpha numeric and special symbols except “&&#8221;
b) Take all digits except “7”
then we cannot prepare a big list which includes all instead we use the symbol of all and exclude the characters / symbols which need to be validated.
Eg: “^\w[^&]*$” is the solution to take all alpha numeric and special symbols except “&&#8221;.

Other Examples:
a) There should not be “1” as first digit,?
^[^1]\d*$ ? this will exclude 1 as first digit.

b) There should not be “1” at any place?
^\d[^1]*$ ? this will exclude the 1 at any place in the sequence.

Note: Here ^ operator is used not only to start the string but also used to negate the values.

Testing of Regular expression:
There are several ways of testing this
a) You can write a windows based program.
b) You can write a web based application.
c) You can even write a service based application.


Windows base sample code:
Here are steps which will be used for regular expression checking in dotNet:

a) Use System.Text.RegularExpression.Regex to include the Regex class.
b) Create an Regex object as follows:
Regex regDollar= new System.Text.RegularExpressions.Regex("^[0-9]*$ ");
c) Call the IsMatch(string object) of the Regex call, which will return true or flase.
d) Depending on the return state you can decide whether passed string is valid for regular expression or not.]

Here is the snap shot code as function:

Public boolean IsValid(string regexpObj, string passedString)
{
//This method is direct method without any exceptional throwing..
Regex regDollar= new System.Text.RegularExpressions.Regex(regexpObj);
return regDollar.IsMatch(passedString);
}

With minor changes to the above function it can be used in windows or webbased or even as a service.

Another way -- Online checking:
At last if you are fed up with above and you have internet connection and you don’t have time to write sample, use the following link to test online

http://www.regexplib.com/RETester.aspx


MORE INFO:
You can find more information on these type of characters at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcharacterescapes.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcharacterclasses.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcongroupingconstructs.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcharacterclasses.asp

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
rezashirazi , posted on 9. March 2008, 09:55

 Flishr is finally released, I worked on it about tow months.


Flishr is a windows application which can help you download any photo from Flickr to your hard disk. It is also a great tool to facilitate uploading your photos to Flickr with just a few clicks and offline settings. You can also search for photos and add favorite ones to your collection and later you can export your collection as a XML file.

you can download Flishr from here. Flishr is free, enjoy it!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
rezashirazi , posted on 7. March 2008, 20:35

Hi ,

There is a command in  vb 6.0 which called 'ZORDER' , it is used to set the order of components or forms in z-index of the page. for example when you have a mdi application and showing mdi childs in it, sometimes you want to show a mdi child in front of other child forms or when another mdi child form is shown on the over of your form, when you show child form again it is not apear in the mdi application because it is back of another form.

"zorder" command is not exist in VB.NET but you can use "object.bringToFront" instead!

Currently rated 3.0 by 3 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

If you save a jpg file in vb.net using : Image.Save(path,imageformat) command, your image will be saved with the low quality, if you want to save a high quality jpg file in vb.net you can use the below source code:

Imports System.Drawing.Imaging

Public Class clsSaveJpeg

' Saves an image as a jpeg image, with the given quality

' Gets:

' path - Path to which the image would be saved.

' quality - An integer from 0 to 100, with 100 being the

' highest quality

Public Shared Sub SaveJpeg(ByVal path As String, ByVal img As Image, ByVal quality As Long)

If ((quality < 0) OrElse (quality > 100)) Then

Throw New ArgumentOutOfRangeException("quality must be between 0 and 100.")

End If

' Encoder parameter for image quality

Dim qualityParam As New EncoderParameter(Encoder.Quality, quality)

' Jpeg image codec

Dim jpegCodec As ImageCodecInfo = GetEncoderInfo("image/jpeg")Dim encoderParams As New EncoderParameters(1)

encoderParams.Param(0) = qualityParam

img.Save(path, jpegCodec, encoderParams)

End Sub

' Returns the image codec with the given mime type

Private Shared Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo

' Get image codecs for all image formats

Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders()

' Find the correct image codec

For i As Integer = 0 To codecs.Length - 1

If (codecs(i).MimeType = mimeType) Then

Return codecs(i)

End If

Next i

Return Nothing

End Function

End Class

 The example is :
  1. Dim myImage As Image = ' ... load the image somehow
  2. ' Save the image with a quality of 50%
  3. SaveJpeg(destImagePath, myImage, 50)

With Special Thanks to Kourosh Derakshan

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5