C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






File exist or not in harddisk


Posted Date: 19 Aug 2008    Resource Type: Code Snippets    Category: AJAX

Posted By: abhay       Member Level: Gold
Rating:     Points: 10



U want to know if file exit or not in harddisk


write these code in client side script

function callajax(str)
{



getreq();

//Build the required Query string
var sPass=1;

var retrieveParam = str;
var retrieveParam = 'id='+ retrieveParam;

var retrieveURL = "AJAXFILECHECK.aspx";

var url = retrieveURL + '?' + retrieveParam;

request.open('GET',url,true);

request.onreadystatechange = filexists;

request.send(null);



}







function filexists()
{
var filename = document.getElementById("myfile").value;
if(request.readyState == 4 )
{


if(request.status == 200)
{

var check = request.responseText;


strStatus = check ;

if(strStatus=="False")
{

alert("file doesn't Exist");

who=document.getElementsByName('myfile')[0];
var who2= who.cloneNode(false);
who2.onchange= who.onchange;
who.parentNode.replaceChild(who2,who);
return false ;

}



}


}

}

function getreq()
{

try
{
request = new XMLHttpRequest();
}
catch(nething)
{
try
{
request = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(othr)
{
try
{
request = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(err)
{
request = false;
}
}
}
if(!request)
{
alert("Error initializing XMLHttpRequest object!");
}
}



And in ajax page that is ajaxfilecheck.aspx


write these codes on page load


private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string strStatus= string.Empty ;
System.Text.StringBuilder strXml;

if(Request.QueryString["id"]!=null)
{

string dirPath=Request.QueryString["id"];

if (System.IO.File.Exists(dirPath)==true)

{
strStatus="True" ;
strXml = new System.Text.StringBuilder ("");
strXml.Append(""+HttpUtility.HtmlEncode(strStatus)+"");



}

else
{
strStatus = "False" ;
strXml = new System.Text.StringBuilder ("");
strXml.Append(""+HttpUtility.HtmlEncode(strStatus)+"");


}
Response.Write(strStatus);

Response.ContentType = "text/xml";
// Response.CacheControl = "No-cache";
// xfile.Save(Response.OutputStream);
}


}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Using Ajax  .  This must help u  .  Hardisk  .  Existence of file  .  C#.net  .  Asp.net  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Display Datetime Without Refreshing the page
Previous Resource: Bind a dropdown according to data in another drop down
Return to Discussion Resource Index
Post New Resource
Category: AJAX


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

fax server

Contact Us    Privacy Policy    Terms Of Use