|
How to round floating point numbers up or down
(Thursday, August 19, 2004)
Rounding floating point numbers up or down
This snippet shows how you can round your floating point numbers up or down (Max or Min range). To calculate the min range (round down) use the following snippet:
'VB Public Function MinRange(ByVal intValue As Integer) As Integer Dim intFactor As Integer intFactor = Math.Pow(10, Len(intValue) - 1) MinRange = Math.Floor(intValue / intFactor) _ * intFactor End Function
To calculate the max range (round up) use the following snippet:
'VB Public Function MaxRange(ByVal intValue As Integer) As Integer Dim intFactor As Integer
intFactor = Math.Pow(10, Len(intValue) - 1) MaxRange = Math.Ceiling(intValue / intFactor) _ * intFactor End Function
Posted by Xander Zelders

How to display the uptime of your (web) server
Determine the uptime of your (web) server
In just one line of code show your public how long your (web) server has been up and running.
Create an empty web form and place a default button and a label on it. In the click event of the button specify this line of code.
'VB Label1.Text = (Environment.TickCount / 1000).ToString & " seconds" This will show the uptime of your server in seconds.
Posted by Xander Zelders

Howto convert a sqlDataReader into a DataTable
converting a sqlDataReader to a DataTable
The following snippet shows how to do this.
//C#
// create the data table DataTable dt = new DataTable("Product"); dt.Columns.Add("ProductID"); dt.Columns.Add("ProductName");
// open the data reader SqlConnection cn = new _ SqlConnection("Data Source=localhost;Initial & _ Catalog=Northwind;User ID=sa;"); SqlCommand cmd = _ new SqlCommand("Select * from products", cn); cn.Open(); SqlDataReader dr = _ cmd.ExecuteReader(CommandBehavior.CloseConnection);
// fill the data table while (dr.Read()) { DataRow row = dt.NewRow(); row["ProductID"] = dr["ProductID"]; row["ProductName"] = dr["ProductName"]; dt.Rows.Add(row); }
Posted by Xander Zelders

How to use the stringbuilder class
Using the stringbuilder class When you're performing extensive string manipulation and performance is an issue, you can not go by the stringbuilder class. Why use a stringbuilder? The most obvious reason to use a stringbuilder is performance. Since in .NET everything is an object, including strings, the regular concatenating involves type conversion.If you're just concatenating a few strings, there's no problem in that, but when you're performing extensive string manipulation, you definitely have to use the stringbuilder.
The simple example below shows you the basics:
'VB Dim sbSample As StringBuilder = New StringBuilder() With sbSample .Append("This is ") .Append("a test.") End With Dim strMyString As String = sbSample.ToString
The stringbuilder class lives in System.Text. So you will have to import that namespace or specify "New System.Text.Stringbuilder".
Besides simple concatenating, ofcourse there's lots of other stuff that can be done.
Posted by Xander Zelders

How to display a byte as a Hex number in C#
Byte to Hex
This codesnippet shows how to display a byte value as a hexadecimal value. // C# byte b = 32; string hexval = b.ToString ('X');
or
// C# byte b = 32; Console.WriteLine("{0:X}",b);
Posted by Xander Zelders

How to extract the time part from a DateTime datatype in C#
How to extract only the time from a DateTime datatype in C#
This example will show how to extract only the time from a DateTime datatype containing a date and a time in C#.
//C# string strDateTime = "01/02/2002 11:30:12 AM";
// Displays 11:30 AM Console.WriteLine(DateTime.Parse(strDateTime).ToShortTimeString()); // Displays 11:30:12 AM Console.WriteLine(DateTime.Parse(strDateTime).ToLongTimeString());
Posted by Xander Zelders

How to replace a line feed in a string with a <BR> tag
Replacing a line feed in a string with a <BR> tag
There are multiple way to replace parts of a string with another parts of a string. In this snippet two examples. The first way is the most common way:
//VB MyString = Replace(MyString, vbCrLf, "<BR>")
But there is a more efficient way, using the stringbuilder.
//C# StringBuilder MyStringBuilder = new StringBuilder(myString); MyStringBuilder = MyStringBuilder.Replace("\r\n","<BR>"); myString=MyStringBuilder.ToString();
Posted by Xander Zelders

How to get the content of an ASCII file into a textbox
Loading the content of an ASCII file into a textbox
The problem is that when an ASCII file is read using 'MyFile.InputStream.Read', it is stored as a binary. Assigning this binary to the Textbox.text would result in non-readable content. The next code will show the way how to do it right.
'VB Dim MyFile As HttpPostedFile = filMyFile.PostedFile Dim nFileLen As Int32 = MyFile.ContentLength Dim MyData(nFileLen) As Byte MyFile.InputStream.Read(MyData, 0, nFileLen) txtTemplate.Text = System.Text.Encoding.ASCII.GetString(MyData)
Posted by Xander Zelders

How to read the content of an external website in a variable
Reading the content of an external website in a variable.
This snippet explains how some searchengines 'crawl' your website and cache it in their database. With this snippet also you know the basics how to build your own spider
'VB.Net Function readHtmlPage(url As String) As String
Dim objResponse As WebResponse Dim objRequest As WebRequest Dim result As String
objRequest = System.Net.HttpWebRequest.Create(url) objResponse = objRequest.GetResponse() Dim sr As New _ StreamReader(objResponse.GetResponseStream()) result = sr.ReadToEnd()
'clean up StreamReader sr.Close() return result
End Function
Posted by Xander Zelders

How to late bind an object, using the 'old' Prog.ID
Late binding an object, using the 'old' Prog.ID
Latebinding in .NET using the createobject("Prog.ID")-function is not possible. Fot his you have to create the following work-around
//C# Type myType = Type.GetTypeFromProgID("Prog.Id"); object myObject = Activator.CreateInstance(myType);
Posted by Xander Zelders

How to parse an ASP.NET page.
parsing an ASP.NET page.
Sometimes it is nessecary to parse the HTML of an ADO.NET page before rendering. For example when converting an old Visual Basic 6 project with webclasses to .NET.
The trick is to override the 'Render'-method of the page. The following example shows how:
'VB Public HTMLPage As String
Protected Overrides Sub Render(ByVal writer As _ System.Web.UI.HtmlTextWriter)
Dim i As Int32 Dim sw As New IO.StringWriter() Dim htmltw As New HtmlTextWriter(sw) Dim sb As System.Text.StringBuilder = _ sw.GetStringBuilder 'Render the controls that are already in the 'template For i = 0 To Page.Controls.Count - 1 Page.Controls(i).RenderControl(htmltw) Next i 'read the HTML of the template and parse it HTMLPage = sb.ToString Response.Write(PageParser(HTMLPage)) end sub
Function PageParser() as String 'Checks for the tags and replaces them with the 'right HTML code End Function
Posted by Xander Zelders

How to determine wether a string fits in a textbox
Find out wether a string fits in a textbox
Often the problem occurs that a string doesn't completely fit in a textbox. Since not every character has the same dimensions a method has to be found to measure the width in pixels of a text string. The following example shows how.
You can use the 'Graphics.MeasureString' method:
'VB Dim myGraphic As Graphics = myTextBox.CreateGraphics() Dim myStringSize As SizeF = myGraphic.MeasureString(string1, myTextBox.Font)
The myStringSize.Width method returns the width in Pixels of the String that would be drawn in the TextBox 'MyTextBox'
Posted by Xander Zelders

How to play sounds using the .NET framework
Playing sounds using the .NET framework
The .NET framework offers more options than the regular 'Beep' command to generate sounds. The following function will show how to use the Windows API. Another example shows how to use the Windows Media Player. For the Windows API:
'VB Private Sub PlayWavFile_Click(ByVal sender _ As System.Object, ByVal e _ As System.EventArgs) Handles PlayWavFile.Click
Dim fileName As String = _ String.Concat(c_soundPath, "\", WaveList.Text) Const SND_FILENAME As Integer = &H20000
PlaySound(fileName, 0, SND_FILENAME) End Sub
Private Declare Auto Function PlaySound Lib _ "winmm.dll" (ByVal lpszSoundName As String, _ ByVal hModule As Integer, ByVal dwFlags _ As Integer) As Integer
For the Windows Media Player:
You have to add the Windows Media Player (COM Component) to your toolbox. Then drag it to your form. If you dont want to see the mediaplayer set the Visible Property to False.
'VB Private Sub playMediaFile(ByVal mediaFileName _ As String) With MediaPlayer .Stop() .FileName = String.Concat _ (c_soundPath, "\", _ mediaFileName) .Play() End With End Sub
Posted by Xander Zelders

Howto convert strings from lower case to upper case.
Converting strings from lower case to upper case.
This will be explained in the next example. To convert "hello world!" to "HELLO WORLD!" do the following.
'C# string myString = "hello world!"; string inUpper = myString.ToUpper();
Posted by Xander Zelders

How to read images from an Access database (OLE object)
Reading images from an Access database (OLE object)
Access bitmaps include 78 bytes of OLE Object header data. You need to remove these bytes from the byte array. when copying an array. One way to do this is to call System.Buffer.BlockCopy which allows you to specify an offset of 78.
Posted by Xander Zelders

How to Print from a rich text box
Printing from a rich text box
For this you can use the following code-snippet.
'VB 'Open file to RTB and print RTB
'To print multiple pages we have to create virtual 'page of text called PrintPage and then add text to it 'until page is full 'Controls: OpenFileDialog1, PrintDocument1, 'PrintDialog1
---------------------------------------------------- Imports System.IO 'for FileStream class Imports System.Drawing.Printing
Public Class Form1 Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code " #End Region
Private PrintPageSettings As New PageSettings() Private StringToPrint As String Private PrintFont As New Font("Arial", 10)
Private Sub btnOpen_Click(ByVal sender As _ System.Object, ByVal e As System.EventArgs) _ Handles btnOpen.Click Dim FilePath As String 'Display Open dialog box and select text file OpenFileDialog1.Filter = "Text files (*.txt)|*.txt" OpenFileDialog1.ShowDialog() 'If Cancel button not selected, load FilePath var If OpenFileDialog1.FileName <> "" Then FilePath = OpenFileDialog1.FileName Try 'Read text file and load into RichTextBox1 Dim MyFileStream As New _ FileStream(FilePath, FileMode.Open) RichTextBox1.LoadFile(MyFileStream, _ RichTextBoxStreamType.PlainText) MyFileStream.Close() 'Initialize string to print StringToPrint = RichTextBox1.Text 'Enable Print button btnPrint.Enabled = True Catch ex As Exception 'display error messages if they appear MessageBox.Show(ex.Message) End Try End If End Sub
Private Sub btnPrint_Click(ByVal sender As _ System.Object, ByVal e As System.EventArgs) _ Handles btnPrint.Click Try 'Specify current page settings PrintDocument1.DefaultPageSettings = _ PrintPageSettings 'Specify document for print dialog box 'and show StringToPrint = RichTextBox1.Text PrintDialog1.Document = PrintDocument1 Dim result As DialogResult = _ PrintDialog1.ShowDialog() 'If click OK, print document to printer If result = DialogResult.OK Then PrintDocument1.Print() End If Catch ex As Exception 'Display error message MessageBox.Show(ex.Message) End Try End Sub
Private Sub PrintDocument1_PrintPage(ByVal _ sender As System.Object, ByVal e As _ System.Drawing.Printing.PrintPageEventArgs) _ Handles PrintDocument1.PrintPage Dim numChars As Integer Dim numLines As Integer Dim stringForPage As String Dim strFormat As New StringFormat() 'Based on page setup, define drawable rectangle Dim rectDraw As New _ RectangleF(e.MarginBounds.Left, _ e.MarginBounds.Top, e.MarginBounds.Width, _ e.MarginBounds.Height) 'Define area to determine how much text can fit 'on a page 'Make height one line shorter to ensure text 'doesn't clip Dim sizeMeasure As New _ SizeF(e.MarginBounds.Width, e.MarginBounds.Height _ - PrintFont.GetHeight(e.Graphics))
'When drawing long strings, break between words strFormat.Trimming = StringTrimming.Word 'Compute how many chars and lines can fit 'based on sizeMeasure e.Graphics.MeasureString(StringToPrint, _ PrintFont, sizeMeasure, strFormat, numChars, _ numLines) 'Compute string that will fit on a page stringForPage = StringToPrint.Substring(0, _ numChars) 'Print string on current page e.Graphics.DrawString(stringForPage, PrintFont, _ Brushes.Black, rectDraw, strFormat) 'If there is more text, indicate there are more 'pages If numChars < StringToPrint.Length Then 'Subtract text from string that has been 'printed StringToPrint = _ StringToPrint.Substring(numChars) e.HasMorePages = True Else e.HasMorePages = False 'All text has been printed, so restore string StringToPrint = RichTextBox1.Text End If End Sub End Class
Posted by Xander Zelders

Pure ASP.NET
(Monday, August 16, 2004)
Pure ASP.NET by Robert Lair, Jason Lefebvre Paperback: 640 pages ; Dimensions (in inches): 1.29 x 8.96 x 5.97 Publisher: Sams; 1st edition (October 15, 2001) Language: Published in English ISBN: 067232069X
From the Back Cover Pure ASP.NET is a premium reference for Active Server Pages development in the new Microsoft .NET Framework. Like all books in the Pure Series, Pure Active Server Pages.NET is comprised of 3 parts. Part I Conceptual Reference is a fast-paced primer that covers ASP.NET fundamentals and concepts. Part II Techniques Reference is full of well-commented, commercial-quality code that illustrates practical applications of ASP.NET concepts. Examples are presented in both Visual Basic and C# to appeal to a wide variety of programmers. Part III Syntax and Object Reference contains detailed coverage of .NET Namespaces such as System.Web and System.Data that are invaluable to ASP.NET developers.
About the Author Robert Lair is a nationally known developer, technical writer, and trainer. He studied computer science and engineering at Wright State University in Dayton, Ohio, and has been working in the area of software development for more than five years. His latest achievements in the software industry include his work on IBuySpy (Vertigo Software), the premiere demo application that shows the new features of ASP.NET. Other applications Robert has worked on in his career include... read more
Book Description Pure ASP.NET is a premium reference for Active Server Pages development in the new Microsoft .NET Framework. Like all books in the Pure Series, Pure Active Server Pages.NET is comprised of 3 parts. Part I Conceptual Reference is a fast-paced primer that covers ASP.NET fundamentals and concepts.Part II Techniques Reference is full of well-commented, commercial-quality code that illustrates practical applications of ASP.NET concepts. Examples are presented in both Visual Basic and C# to appeal to a wide variety of programmers. Part III Syntax and Object Reference contains detailed coverage of .NET Namespaces such as System.Web and System.Data that are invaluable to ASP.NET developers.
Posted by Xander Zelders

Visual Basic .NET Code Security Handbook
Visual Basic .NET Code Security Handbook by Eric Lippert Paperback: 350 pages ; Dimensions (in inches): 0.70 x 8.98 x 6.38 Publisher: Wrox Press; (August 1, 2002) Language: Published in English ISBN: 1861007477
Book Info Focuses exclusively on code level security considerations and provides a VB.NET perspective. For VB programmers who want language specific information. Softcover.
From the Publisher When security vulnerabilities are discovered in your products or systems it is not only embarrassing but also potentially costly to you and or your customers. .NET offers the potential to reduce greatly the number and severity of security vulnerabilities but there are still many pitfalls; this book can help you avoid them.
Book Description .NET provides a powerful framework in which to write secure code but unless you understand how attackers think and how the .NET security systems works your code will be vulnerable. Writing secure .NET code requires three things: an understanding of the .NET code security system, attention to detail, and the ability to think from the point of view of an attacker. This book provides a practical guide to the .NET security framework, and also demonstrates best practices to follow and worst practices to avoid. There is no such thing as foolproof security but the techniques demonstrated in this book will go a long way towards making your code secure in the face of attackers.
As well as knowing how to write secure code, it is also important to be able to spot holes in your own and others code. This book provides many examples of common vulnerabilities (and how to mitigate them) to help you learn this important skill.
Although this book primarily focuses on .NET code access security other aspects of security such as the Window role based security model, cryptography, and calling unmanaged code are covered where relevant.
Posted by Xander Zelders

Obfuscating .NET: Protecting Your Code from Prying Eyes [DOWNLOAD: PDF]
Obfuscating .NET: Protecting Your Code from Prying Eyes [DOWNLOAD: PDF] by Dan Appleman, Daniel Appleman Format: Adobe Reader (PDF) Printable: Yes. This title is printable Mac OS Compatible: OS 9.x or later Windows Compatible: Yes Handheld Compatible: Yes. Adobe Reader is available for PalmOS, Pocket PC, and Symbian OS. Digital: 77 pages Publisher: Daniel Appleman; ISBN: B00006488E; (March 18, 2002)
Download Description Did you know you actually ship your source code every time you distribute a .NET assembly? One of the consequences of the architecture of .NET is that a great deal of information about an assembly is kept with the assembly in a part of the file called the Manifest. This information makes it remarkably easy to not just reverse engineer the assembly, but to decompile it, make modifications, then recompile it. While such reverse engineering has always been possible, it is extraordinarily easy with .NET - a situation that is a significant problem to anyone distributing .NET applications or components who is concerned about protecting their intellectual property.
In this PDF E-Book, you'll learn about a technique called Obfuscation, that can help you avoid this problem. And you'll receive an in depth look at one particular approach to obfuscating your .NET assemblies, along with a link to a free download of Desaware's open source QND-Obfuscator.
Posted by Xander Zelders

Database Programming with Visual Basic .NET and ADO.NET
Database Programming with Visual Basic .NET and ADO.NET by F. Scott Barker Paperback: 544 pages ; Dimensions (in inches): 1.19 x 9.06 x 7.32 Publisher: SAMS; 1st edition (September 12, 2002) Language: Published in English ISBN: 0672322471
From the Back Cover The topic combination of VB .NET and ADO.NET is unbeatable. VB .NET is the most popular language in which to code. And, every developer needs to understand ADO.NET to allow data to be accessed from a Web site. In this book Developers will be shown numerouse code examples that will illustr4ate how to program database driven applications within the .NET Framework. The book is aimed at both established and new VB Developers. Important topics covered include: Visual Studio development environment, ASP.NET applications, Windows Forms application, using VB .NET with ADO.NET, complex queries, security, COM interop., and application deployment.
About the Author F.Scott Barker has worked as a database developer for more than 15 years. He now contracts with Microsoft and the Access team by developing in-house tools used throughout Microsoft. Scott has trained for Application Developers Training Company and others all around the United States. He is a frequent speaker at Access conferences throughout the U.S., Canada, and Europe, including Tech Ed. Scott has written articles for: Smart Access(Pinnacle), Data Based Advisor Magazine (Advisor), Access,... read more
Book Description The topic combination of VB .NET and ADO.NET is unbeatable. VB .NET is the most popular language in which to code. And, every developer needs to understand ADO.NET to allow data to be accessed from a Web site. In this book Developers will be shown numerouse code examples that will illustr4ate how to program database driven applications within the .NET Framework. The book is aimed at both established and new VB Developers. Important topics covered include: Visual Studio development environment, ASP.NET applications, Windows Forms application, using VB .NET with ADO.NET, complex queries, security, COM interop., and application deployment.
Posted by Xander Zelders

Moving to VB .NET
Moving to VB .NET by Dan Appleman Paperback: 640 pages ; Dimensions (in inches): 1.58 x 9.04 x 7.18 Publisher: Apress; 02 edition (April 8, 2003) Language: Published in English ISBN: 159059102X
Book Info A professional networker's guide to making the transition to VB.NET. Shows how to master key concepts such as multithreading, inheritance, and .NET memory management. Also provides the key to working with the new code required for VB.NET. Softcover. --This text refers to an out of print or unavailable edition of this title.
Book Description In this new edition of his popular title, "Moving to VB .NET", Visual Basic guru Dan Appleman not only updates the book to include coverage of changes to VB.NET in Visual Studio 2003, but extends those areas that have proven important to VB.Net programmers since its release. Topics such as .Net remoting, versioning and object oriented programming are further illuminated using his own personable and highly effective style. Appleman not only explains the technology features of VB .NET, but the reasons for them, and the controversies around some of those choices. Evaluating VB NET from the perspective of the developer, you'll find material that may infuriate everybody from staunch VB traditionalists to Microsoft marketing staff. Most importantly the reader will learn to write good quality VB .NET code in well-designed applications. Appleman brings the same attention to technical detail and real world attitude to "Moving to VB .NET" 2nd Edition, he has brought to all his past books, and is a sure winner with readers.
Posted by Xander Zelders

Hijacking .Net Vol 2: Protecting Your Code [DOWNLOAD: PDF]
Hijacking .Net Vol 2: Protecting Your Code [DOWNLOAD: PDF] by Dan Appleman, Daniel Appleman Format: Adobe Reader (PDF) Printable: Yes. This title is printable Mac OS Compatible: OS 9.x or later Windows Compatible: Yes Handheld Compatible: Yes. Adobe Reader is available for PalmOS, Pocket PC, and Symbian OS. Digital: 29 pages Publisher: Daniel Appleman; ISBN: B0000CDS9Z; (August 24, 2003)
Download Description Volume 1 of Hijacking .NET introduced today's equivalent of using undocumented Windows API functions. Except that not only are the functions under discussion undocumented, they are actually private - functions internal to the .NET framework that were never intended to be used from outside. But the same techniques used to hijack hidden features of the .NET framework can be used on your assemblies as well. In volume 2, you'll learn about security issues relating to private member access, how to spot potential vulnerabilities in your own code, and how to protect and secure your code from these techniques.
Security in general is an increasingly important topic, and the design patterns taught in this book can help you anticipate and avoid costly security problems down the road.
Posted by Xander Zelders

Visual C ++ .NET
Visual C ++ .NET by Harvey M. Deitel, Paul J. Deitel, Christina Courtmarche, Jeffrey Hamm, Jonathan P. Liperi, Tem R. Nieto, Cheryl H. Yaeger Paperback: 1622 pages ; Dimensions (in inches): 2.24 x 9.18 x 7.14 Publisher: Prentice Hall PTR; 1st edition (November 21, 2002) Language: Published in English ISBN: 013045821X
Back Cover Copy Practical, example-rich coverage of: - Visual Studio .NET IDE - .NET Framework Class Library - Classes, Inheritance and Polymorphism - Graphical User Interface Programming - Exception Handling, Networking - XML and XML Processing - Databases, SQL and ADO .NET - ASP .NET Web Services - Managed and Unmanaged Code - ATL Server and Web Applications - COM Interoperability Services and more... - The experienced programmer's DEITEL LIVE-CODE guide to VisualC++ .NET and the powerful Microsoft .NET Framework.
Posted by Xander Zelders

.Net Framework
.Net Framework by Wrox Team Paperback Publisher: CampusPress; (January 22, 2002) ISBN: 2744090093
Posted by Xander Zelders

Microsoft SQL Server 2000 Developer
by Microsoft
Features: - A restricted version of SQL Server for testing and development - Sample the functionality of the Enterprise Edition before buying the full product - Fully Web-enabled database - Rich support for XML - Secure HTTP database connectivity
Amazon.com Product Description SQL Server Developer Edition is a version of SQL Server with some restrictions on functionality, and is designed for development and testing purposes. It is ideal for those developers who want to get a taste of the Enterprise Edition before purchasing the full product. The description following applies to the full product. SQL Server 2000 is a fully Web-enabled database product, providing core support for XML and the ability to query across the Internet and beyond the firewall. Its features include a data-mining feature called Analysis Services, which lets anyone with SQL and Microsoft Visual Basic programming experience use OLAP tools to create custom analysis applications. Using a middle-tier server, SQL Server 2000 can perform complex analyses on large volumes of data with exceptional data-retrieval performance. Two new features, linked OLAP cubes and HTTP access to cubes, offer powerful data analysis over the Web. In addition to enabling you to extend your analysis capabilities to partners outside the firewall, these features deliver new value by creating opportunities to sell access to your database to new customers over the Web.
SQL Server 2000 extends your e-commerce functionality through rich support for XML, easy Web access to database information, and powerful analysis tools, coupled with high availability and tight security. This means that Web developers can access data using XML without having to do complex programming, and database administrators can manipulate data easily in XML format using Transaction SQL (T-SQL) and stored procedures. Secure HTTP database connectivity ensures that data can be queried--even by relatively inexperienced users--through a URL and intuitive user interfaces. SQL Server 2000 also makes querying from the Web relatively easy. The enhanced English Query tool allows developers to build natural, English-language interfaces to SQL Server in Microsoft Visual Studio. In addition, English Query can now generate Multidimensional Extensions (MDX) to query against OLAP cubes.
Posted by Xander Zelders

How can I upload larger files with ASP.NET?
(Sunday, August 15, 2004)
By default, the file size limit on uploads in ASP.NET is 4mb. Most of the time, the default 4Mb is more than enough to upload files using the POST method in webforms. But sometimes more is needed. The following example shows how.
To upload larger files through HTTP, you can use a configuration setting in your application Web config file or your machine Web config file:
<configuration> <system.web> <httpRuntime maxRequestLength="10000" /> <authorization> <deny users="?"/> </authorization> </system.web> </configuration>
where "10000" is the max file size in Kbytes that you want to allow
Posted by Xander Zelders

How can I upload larger files with ASP.NET?
By default, the file size limit on uploads in ASP.NET is 4mb. Most of the time, the default 4Mb is more than enough to upload files using the POST method in webforms. But sometimes more is needed. The following example shows how.
To upload larger files through HTTP, you can use a configuration setting in your application Web config file or your machine Web config file:
<configuration> <system.web> <httpRuntime maxRequestLength="10000" /> <authorization> <deny users="?"/> </authorization> </system.web> </configuration>
where "10000" is the max file size in Kbytes that you want to allow
Posted by Xander Zelders

|
|
|
|