TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sandeep Gudipelli
NA
1
902
Access local machine folder items
Mar 17 2014 1:51 PM
I am rewriting an VB6 desktop application into Web application, since its a desktop application its using the users local machine folder to view word documents. I want to implement the same in the web application. I don't want to use the server documents, instead I want to use the users local machine to access those documents.
protected void Page_Load(object sender, EventArgs e)
{
BasDebugMessages debug = new BasDebugMessages();
string strWordTemplatePath = "";
string strInitialFile = "";
try
{
string strWordTemplate = Request.QueryString["file"].ToString();
string PersonType = Request.QueryString["PersonTypeCode"].ToString();
ViewState["PersonTypeCode"] = PersonType;
if (PersonType == "A")
{
strWordTemplatePath = "C:\\Program Files\\Microsoft Office\\Templates\\APS Reports\\";
strInitialFile = strWordTemplatePath + "B2590.ini";
}
else
{
strWordTemplatePath = "C:\\Program Files\\Microsoft Office\\Templates\\JAS Reports\\";
strInitialFile = strWordTemplatePath + "A2580.ini";
}
string strWordTemplateDot = Path.GetFullPath(strWordTemplatePath + strWordTemplate + ".dot");
if (!File.Exists(strInitialFile))
{
StreamWriter sw = File.CreateText(strInitialFile);
}
System.IO.FileInfo file = new System.IO.FileInfo(strWordTemplateDot);
if (file.Exists)
{
string path = file.DirectoryName + "\\" + strWordTemplate + ".dot";
FileStream outputfile = new FileStream(path, System.IO.FileMode.Open);
byte[] fileData = new byte[outputfile.Length];
outputfile.Read(fileData, 0, Convert.ToInt32(outputfile.Length));
outputfile.Close();
EditIniFile(strInitialFile, strWordTemplate);
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Expires = 0;
HttpContext.Current.Response.ContentType = "application/msword";
HttpContext.Current.Response.AppendHeader("content-disposition", "attachment; filename= " + file.Name);
HttpContext.Current.Response.BinaryWrite(fileData);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
}
catch (ThreadAbortException)
{
}
catch (Exception ex)
{
debug.Insert(ex.Message);
}
}
Reply
Answers (
0
)
wcf in mvc ? help
Architectural flow @MVC4 ?