<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script Language="C#" runat="server">
void Page_Load(Object sender, EventArgs e) {
// path to directory
string strPath = "E:/users/john/personal/files/";
// create an instance of the DirectoryInfo object
DirectoryInfo objTestDirectory = new DirectoryInfo(strPath);
if(objTestDirectory.Exists) {
output.Text = "Yes, the directory <b>" + strPath + "</b> exists.";
} else {
output.Text = "No, the directory <b>" + strPath + "</b> does not exist.";
}
}
</script>
<html>
<head></head>
<body>
<asp:label id="output" runat="server" style="font: 14px, Arial" /> </body> </html> <%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script Language="C#" runat="server">
void Page_Load(Object sender, EventArgs e) {
// path to the file
string strFilePath = "E:/users/john/personal/files/Test_Document.doc";
// create an instance of the FileInfo object
FileInfo objTestFile = new FileInfo(strFilePath);
if(objTestFile.Exists) {
output.Text = "The file <b>" + strFilePath + "</b> was found. Here is more information: ";
output.Text += "Name: " + objTestFile.Name + "";
output.Text += "Location: " + objTestFile.FullName + "";
output.Text += "Created on: " + objTestFile.CreationTime + "";
output.Text += "Last modified on: " + objTestFile.LastWriteTime + "";
output.Text += "File size (in bytes): " + objTestFile.Length.ToString() +
"";
output.Text += "Extension: " + objTestFile.Extension;
} else {
output.Text = "Sorry, the file <b>" + strFilePath + "</b> was not found.";
}
}
</script>
<html>
<head></head>
<body>
<asp:label id="output" runat="server" style="font: 14px, Arial"/> </body> </html> serkan sendur
Postaholic
Banned
2,062 posts since Jan 2008
Reputation Points: 854
Solved Threads: 127