Thursday, September 22, 2005

How to increase the request size limit and make possible the upload of larger files?

If you ever used the ASP.NET file upload control you may be
have noticed that if you try to upload a file which size
exceeds 4MB, the upload failes.
The reason for this is the ASP.NET precaution against
denial-of-service attacks which by default limits the
size of the requests at 4MB.
However if in your application you need to upload larger files
you may increase this limit, by simply modifying the
maxRequestLength attribute in your machine.config file
...

How to get the host name from an IP address?

public string getHost(string ip)
{
IPHostEntry IpEntry = Dns.GetHostByAddress(ip);
return iphostentry.HostName.ToString();
}

How to strip the HTML tags from text with C# and Regular expression?

string strResult = Regex.Replace(strInput,@"<(.|\n)*?>",string.Empty);

Thursday, June 23, 2005

Switch Options for Windows NT Boot.ini File

Available Switch Options for Windows NT Boot.ini File

SQL TRUNCATE

If you want to clear out a table in MS SQL that includes an identity field AND want to reset the field so it starts over at 1, use TRUNCATE instead of DELETE FROM.

Tuesday, June 14, 2005

Windows Media Player 8,9,10 CD to MP3:

HKLM\SOFTWARE\Microsoft\MediaPlayer\Settings\MP3Encoding
SetValue "HighRate"=dword:0001F400 (128000)
HKLM\SOFTWARE\Microsoft\MediaPlayer\Settings\MP3Encoding
SetValue "MediumHighRate"=dword:0001B580 (112000)
HKLM\SOFTWARE\Microsoft\MediaPlayer\Settings\MP3Encoding
SetValue "MediumRate"=dword:0000FA00 (64000)
HKLM\SOFTWARE\Microsoft\MediaPlayer\Settings\MP3Encoding
SetValue "LowRate"=dword:0000DAC0 (56000)

WinXP Home to XP Pro Lite - ?????

HKEY_LOCAL_MACHINE\Homekey\ControlSet001\Services\setupdd
key Standard format REG_BINARY all 0
01 --> 00
02 --> 00

or:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\ProductOptions
set to empty, than reboot to last known good config..

or use NTSwitch.

Monday, March 21, 2005

Close All for VS 2003

Imports EnvDTE
Imports System.Diagnostics

Public Module CloseAll
Private maxTries As Integer = 3
Sub CloseAll()
Dim currentTries As Integer = 0
While (Not exeClose()) And currentTries < maxTries
currentTries += 1
End While
End Sub

Function exeClose() As Boolean
Try
For Each d As Document In DTE.Documents()
d.Close(vsSaveChanges.vsSaveChangesPrompt)
Next
Catch
Return False
End Try

Return True
End Function

End Module

Saturday, March 19, 2005

AccessorsCreator for VS

Imports EnvDTE
Imports System.Diagnostics

Public Module AccessorsCreator
Sub createAccessor()
Dim selected As String = DTE.ActiveDocument().Selection.text()
If (selected Is Nothing Or selected.Length = 0) Then
Exit Sub
End If

selected = selected.Replace(",", "")
selected = selected.Replace(";", "")
Dim parts() As String = selected.Split(" ")
Dim memberCount As Integer = parts.Length - 2

Dim basicOutput As String = "public $TYPE$ $PROP_NAME$ {" & vbCrLf _
& vbTab & "get { return $MEMBER_NAME$; }" & vbCrLf _
& vbTab & "set { $MEMBER_NAME$ = value; }" & vbCrLf _
& "}" & vbCrLf & vbCrLf

Dim results(memberCount) As String
For i As Integer = 2 To parts.Length - 1
Dim propName As String
propName = parts(i).Substring(0, 1).ToUpper() & parts(i).Substring(1)
results(i - 2) = basicOutput.Replace("$MEMBER_NAME$", parts(i))
results(i - 2) = results(i - 2).Replace("$PROP_NAME$", propName)
results(i - 2) = results(i - 2).Replace("$TYPE$", parts(1))
Next

Dim entryLine As Integer = DTE.ActiveDocument().Selection.BottomLine + 1
DTE.ActiveDocument().Selection.GotoLine(entryLine)

For i As Integer = 0 To results.Length - 1
DTE.ActiveDocument().Selection.Insert(results(i))
Next
End Sub
End Module