Book Image

Beginning C# 7 Hands-On ??? Advanced Language Features

By : Tom Owsiak
Book Image

Beginning C# 7 Hands-On ??? Advanced Language Features

By: Tom Owsiak

Overview of this book

Beginning C# 7 Hands-On – Advanced Language Features assumes that you’ve mastered the basic elements of the C# language and that you're now ready to learn the more advanced C# language and syntax, line by line, in a working Visual Studio environment. You'll learn how to code advanced C# language topics including generics, lambda expressions, and anonymous methods. You'll learn to use query syntax to construct queries and deploy queries that perform aggregation functions. Work with C# and SQL Server 2017 to perform complex joins and stored procedures. Explore advanced file access methods, and see how to serialize and deserialize objects – all by writing working lines of code that you can run within Visual Studio. This book is designed for beginner C# developers who have mastered the basics now, and anyone who needs a fast reference to using advanced C# language features in practical coding examples. You'll also take a look at C# through web programming with web forms. By the time you’ve finished this book, you’ll know all the critical advanced elements of the C# language and how to program everything from C# generics to XML, LINQ, and your first full MVC web applications. These are the advanced building blocks that you can then combine to exploit the full power of the C# programming language, line by line.
Table of Contents (35 chapters)
Title Page
Credits
About the Author
www.PacktPub.com
Customer Feedback
Preface

Chapter 23. Creating a Page That Uses the File Upload Control

In this chapter, you will learn how to use the Upload feature in ASP.NET. To do this, we will create an interface with the following controls on the page:

Figure 23.2.1: The controls for our user interface

When you click on the Browse button, you should get some sample files, as shown in Figure 23.2.2. Select one of these files, for example, samp.txt:

Figure 23.2.2: The C:\data directory file listing

Now, when you click on the Upload button, and once the file is uploaded, browser will display a message like the one shown in Figure 23.2.3, displaying where the files have been uploaded, how many files are inside the directory, and what they are named. This is our objective here:

Figure 23.2.3: Message displayed when the Upload button is clicked

Make sure that you have data as a folder in the root directory of your hard drive, and within that folder, you have another folder called uploads. To do this at the command-line level, go to Command...