Dear all,

How do I access folder+files is located outside webfolder ?
My Intranet application website address is http://160.115.30.20/BMI
and physical folder in server is C:\Inetpub\wwwroot\BMI.
Folder I want to acess is located in C:\Inetpub\wwwroot\Documents.

Now, The folder is in webfolder. I want to move it to outside webfolder to make it simple when backup programs or documents.

Thanks,

Kusno.

<%@ 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: <br />";
		output.Text += "Name: " + objTestFile.Name + "<br />"; 
		output.Text += "Location: " + objTestFile.FullName + "<br />"; 
		output.Text += "Created on: " + objTestFile.CreationTime + "<br />"; 
		output.Text += "Last modified on: " + objTestFile.LastWriteTime + "<br />"; 
		output.Text += "File size (in bytes): " + objTestFile.Length.ToString() +
"<br />";				
		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>

Dear Serkan Şendur,

Thanks for you reply.
Sorry, I think I did not give clearly question to all members.

In my folder there are pdf file and images file.
Users upload files from their local drive to that folder and if users want to see those file
I can use Response.Redirect command.

Thanks,

Kusno

one user email me about further explanation to this problem. you can access any file or folder on the server as long as you have the appropriate ntfs and share permissions. these permissions must be granted to ASP.NET user.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.