Hi Ravi,
You are absolutely right, a postbackurl checks with in the solution explorer. The Server is accessible till the website folder under which it is running. That's why we include all the files with in our Solution that are necessary to run our application. Referring to other directory files, you will be reported with an alert "Browser doesn't support its address.. because the protocol is not associated with any program."
On click of the image button, you can include a funtion to open the text file:
protected void open(Object sender, EventArgs e)
{
FileStream content = System.IO.File.Open(@"c:\test.txt", System.IO.FileMode.Open); // Directly open the file or copy the file content into another and open.
}
If you want to open a remote file.. Server.MapPath doesn't work as it refers to the local system only. Info on internet says that you can directly
FTP files from .net using FtpWebRequest. or Include the file under webservice to access it on remote.
Using FtpWebRequest:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/output.txt"); // Your file path.
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com"); // Mention the network credentials to look into you shared files.. ftp accessing files
Stream requestStream = request.GetRequestStream();
requestStream.Write(stuff); // write your stuff here
requestStream.Close();
// You can also update a remote file content
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();
This might not be a perfect solution.. as far as i searched the info, can bring you an idea.
If it is helpful to you, mark it as answer.. it might help others.
Regards,
Awesome Coding !! :)
Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator