Monday, July 26, 2010

Visuanl C # 2005 Quick Start of the while statement (1)



Use while statements can be true in a Boolean expression is subject to repeat the run a statement.
while statement syntax is as follows:
while (booleanExpression)

statement


First, the Boolean expression will be evaluated, if it is true, on the run statement, then the Boolean expression is evaluated again. If the expression is still true, to run the statement again, and again the expression is evaluated. This process will continue repeatedly until the boolean expression evaluates to false; time, while statement will exit, and from the first statement after the while continue. while statement syntax with if statements have many similarities (in fact, in addition to the two different keywords, the syntax is exactly the same):

鈼?expression must be a Boolean expression.

鈼?Boolean expression must be placed within parentheses.

鈼?If the first value, the Boolean expression is false, statement is not run.

鈼?If you want to in a while under the control of the implementation of two or more statements, you must use braces to group into a block statement.

The following while statement is written to the console the value 0 to 9:
int i = 0;

while (i! = 10)

(

Console.WriteLine (i);

i + +;

)


All the while statement should be terminated at some point. Novice common mistake is to forget to add a special statement, it would eventually result in a Boolean expression evaluates to false and terminate the cycle. In the example, i + +; on this situation.

Note that while loop variable i controls the final number of cycles. This is a very popular representation, has the effect of the variable is sometimes called the sentinel variable (Sentinel variable).

In the following exercise, preparing to write a while loop, it is time to read from a source file line content, and write each line of a text box.

鈼?use the while statement

1. WhileStatement open Visual Studio 2005 project, which is located in My Documents folder under the Microsoft PressVisual CSharp Step by StepChapter 5WhileStatement subfolders.

2. Select "Debug" | "to start (not debugging)."

Visual Studio 2005 to build and run the Windows application. Application itself is a simple text file viewer that allows you to select a file to display its contents.

3. Click the "Open File" (Open File) button.

Then there are "Open" dialog box

4. Switch to the My Documents folder under the Microsoft PressVisual CSharp Step by Step Chapter 5WhileStatementWhileStatement subfolders.

5. Select the Form1.cs file, and then click "Open."

Form1.cs file name will be displayed in small text box, but the contents of the file does not display in the large text box. This is because we have not achieved the appropriate code to read the contents of the source file and display those in the large text box contents. The following steps will add this feature.

6. Close the form, return to Visual Studio 2005.

7. In the "Code and Text Editor" window displays the file Form1.cs code, find openFileDialog_FileOk method.

Users in the "Open" dialog box, select a file, and click "Open" button, call the method. Method is currently the subject:
string fullPathname = openFileDialog.FileName;

FileInfo src = new FileInfo (fullPathname);

filename.Text = src.Name;

/ Bin / boot / dev / etc / home / lib / lost + found / media / misc / mnt / net / opt / proc / root / sbin / selinux / srv / sys / tmp / u01 / usr / var / vmware add while loop here backup / bin / conf / data / log / maint / svn / tmp /


The first statement declares a string variable, named fullPathname, and it is initialized to openFileDialog object FileName property. The statement fullPathname initialized to "Open" dialog box, select the source file's full name (including path).

Note openFileDialog object is from the "toolbox" of selected components of an instance of the OpenFileDialog. This component provides the methods used, you can display to the user a standard Windows "Open" dialog box, allowing users to choose a file, and get selected file name and path.







相关链接:



3D TV is a pie or a bubble?



"Plant Wars zombie" Endlss50 splash breakthrough detailed Raiders



Sneak Peek! VIDEOSTUDIO 10 Plus the first to experience



First Financial Weekly: Direct Supply In The Shadow Of Digital China



Audio file converter



Multimedia courseware in teaching and learning and its CORRECTION



Streaming Media common sense: the basic principles of stream



M4v to flv



Converter mp4 to 3gp free download



ISV Tomorrow Where?



Fax Tools Reviews



evaluation Multimedia Creation TOOLS



flv to mp3 converter free download



To-day thinking of a fulcrum, it will HOLD up the entire dagali



Infomation Shell Tools



China's largest drilling company defectors brush out of legal counsel, the Credit risk of specul



Monday, July 12, 2010

ASP.net (C #) bulk upload



Upload pictures for this site needs, refer to a lot of mature experience in the ASP.net platform using C # language, to do this automatically bulk upload images. ASPX file, and by the debugged, the use of this site, are sent to for your reference, I hope more master pointers.
The program main features are:

(1) can upload their own need to change the directory to the server, upload the source image, thumbnails, text watermark, image watermark charts to map and set the directory into the different directories;

(2) automatically checks the directory, such as nothing to the selected directory, will automatically create them;

(3) the size of thumbnails generated its own set;

(4) can choose whether to need to generate a text watermark, image watermark, watermark map not generated by default;

(5) can add, delete needed to upload pictures.

In this process the relevant comments were added, so issue a code, no explanation.

Daemon:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;

/ / /
/ / / FileUpload1.HasFile If this is true, is that there are files to upload to the control
/ / / FileUpload1.FileName return to upload the file name, does not contain path information
/ / / FileUpload1.FileContent returns a pointer to the uploaded file stream object
/ / / FileUpload1.PostedFile return has a reference to upload files
/ / / FileUpload1.PostedFile.ContentLength return to upload the file that the file size in bytes
/ / / FileUpload1.PostedFile.ContentType return to upload the file MIME content type, that is, file type, such as return "image / jpg"
/ / / FileUpload1.PostedFile.FileName file on the client to return the full path (including file name full name)
/ / / FileUpload1.PostedFile.InputStream returns a pointer to the uploaded file stream object
/ / / FileInfo object that location on the disk or network files. Providing file path, you can create a FileInfo object:
/ / /

public partial class BackManagement_ImagesUpload: System.Web.UI.Page
(
public string treePath = "";
public int imageW = 100;
public int imageH = 100;
protected void Page_Load (object sender, EventArgs e)
(
this.Button5.Attributes.Add ("Onclick", "window.close ();"); / / in the local close the current page, without the need to send to the server to close the current page
if (! Page.IsPostBack)
(
Label2.Text = Server.MapPath ("/");
TextBox3.Text = "ImageUpload";
treePath = Server.MapPath ("/") + TextBox3.Text.Trim () + "/";
TextBox4.Text = imageW.ToString ();
TextBox5.Text = imageH.ToString ();
)
)
protected void btnload_Click (object sender, EventArgs e)
(
/ / If you save the image directory does not exist, create it by the
treePath = Server.MapPath ("/") + TextBox3.Text.Trim () + "/";
imageW = Convert.ToInt32 (TextBox4.Text.ToString ());
imageH = Convert.ToInt32 (TextBox5.Text.ToString ());
if (! File.Exists (treePath + "images")) / / if / ImageUpload / images do not exist, create / ImageUpload / images, used to store the source image
(
System.IO.Directory.CreateDirectory (treePath + "images");
)
if (! File.Exists (treePath + "thumbnails")) / / if / ImageUpload / thumbnails do not exist, create / ImageUpload / thumbnails, thumbnail images for storage
(
System.IO.Directory.CreateDirectory (treePath + "thumbnails");
)
if (! File.Exists (treePath + "textImages")) / / if / ImageUpload / textImages

Does not exist, create / ImageUpload / textImages, used to store text watermark image
(
System.IO.Directory.CreateDirectory (treePath + "textImages");
)
if (! File.Exists (treePath + "waterImages")) / / if / ImageUpload / waterImages does not exist, then create / ImageUpload / waterImages, used to store graphic image watermark
(
System.IO.Directory.CreateDirectory (treePath + "waterImages");
)

if (FileUpload1.HasFile) / / If this is true, is that there are files to upload the control
(
string fileContentType = FileUpload1.PostedFile.ContentType;
if (fileContentType == "image / bmp" | | fileContentType == "image / gif" | | fileContentType == "image / pjpeg")
(
string name = FileUpload1.PostedFile.FileName; / / return files on the client's full path (including file name full name)

FileInfo file = new FileInfo (name); / / FileInfo object that location on the disk or network files. Providing file path, you can create a FileInfo object:
string fileName = file.Name; / / file name
string fileName_s = "x_" + file.Name; / / thumbnail file name







Recommand Link:



free converter Mp4 to 3gp



Youtube to Cell Phone Pro



avi to 3gp CONVERTER free download



Mp4 Converter To Avi



Hot Nature - Screen Savers



Hope DVD Google Video MPEG Editor



Infomation Games Board



comparison GENEALOGY



Plato iPhone PACKAGE



Hot Real Video Converter



My favorite Management And Distribution



M4v



Christmas-Idea VCD DAT To Xbox 360



SecondLife DVD Cloner



Merry CD-R Sound CDA to WMA Creator