This tutorial shows how we can verify that the file exists or does not receive the execution code representations about the file. The version in C #.
It can be very useful to perform certain lines of code before checking for a file. It prevents error messages from attempting to manipulate files that do not exist, for example. Using System.IO, we can see if there is a file available in a directory that is convenient.
Using System.IO;
Server intelligence assists, businesses of all sizes and their hosting needs, provide fully configured server solutions plus Active Server Management services. Server Intelligence specializes in providing complete Internet server solutions and stands ready to support their expert twenty four-three hundred and sixty fifths active support team.
The ASPX page looks like this:
<form id= "Form1" runat= "Server" >
Search for a file (inc. extension to = if it exists in the media directory.<br/>
Hint:try delete.gif<br/>
<br/>
<asp:textbox id= "TextBox1" runat= "Server" ></asp:textbox><br/>
<asp:button id= "Button1" runat= "server" text= "Go"/><br/>
<asp:label id= "Label1" runat= "Server" ></asp:Label>
</form> |
We migrated to the website server intelligence one weekend and the installation was so smooth that we were starting and running out. They help us with everything we need to do with all the apps. With the help of the server intelligence, we can avoid any trouble www.111cn.net/!
Logical check to see if there is any text when the button is pressed first. If there is text currently, it will check to see if this text file is a folder on the media. The user will be notified if there is a file or not.
Code-behind looks like this:
Using System;
Using System.Data;
Using System.Configuration;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Using System.IO;
public partial class _default:system.web.ui.page
{
protected void Page_Load (object sender, EventArgs e)
{
if (IsPostBack)
Doesfileexist (TextBox1.Text);
}
public void Doesfileexist (string searchstring)
{
if (TextBox1.Text!= "")
{
String Imagefolder;
Imagefolder = Server.MapPath ("/media/") + searchstring.tostring ();
if (file.exists (Imagefolder))
{
Label1.Text = "File <b>" + searchstring + "</b> <u>does</u> exist in '/media/' folder."
}
Else
{
Label1.Text = "File <b>" + searchstring + "</b> <u>does not</u> exist in '/media/' folder."
}
}
Else
Label1.Text = "Please enter some Text."
}
}
Reprint Please specify: www.111cn.net/net/net.html