Access to Shared folder from asp.net | | |
Hello,
How can I access a Shared Folder of the Server by using the following control.
1. I need to download files from c:\resumes folde by using the following;
<asp:HyperLink
NavigateUrl='<%#DataBinder.Eval(Container.DataItem ,"FilePath") %>'
a. FilePath is a database field holding the value "c:\resumes\myresume.doc"
b. NavigateUrl will prefix the virtual path & then the filepath.
Any thoughts are welcome | | | | re: Access to Shared folder from asp.net
I'm doing something similar on a web application. For various reasons, I
pulled a copy of the document (a PDF) into a temporary directory under the
website that I associated with a particular user. When the user's session
expires (or when they log off), I clear their cache. For my requirements and
my application, this was the best choice.
You might want to look at streaming the document directly into a webpage
rather than allowing anonymous users access to the resume directory. Giving
anon users access to a shared folder is a security problem. At least make
sure the user account under which access will be granted (aspnet or whatever
in your case) has read-only access...
"Ibrahim." wrote: Quote:
Hello,
>
How can I access a Shared Folder of the Server by using the following control.
>
1. I need to download files from c:\resumes folde by using the following;
>
<asp:HyperLink
NavigateUrl='<%#DataBinder.Eval(Container.DataItem ,"FilePath") %>'
>
a. FilePath is a database field holding the value "c:\resumes\myresume.doc"
>
b. NavigateUrl will prefix the virtual path & then the filepath.
>
Any thoughts are welcome
>
>
| | | | re: Access to Shared folder from asp.net
Instead of using a Hyperlink that directly links to the shared folder, use a
button (or a buttoncolumn in a datagrid). On the server side while processing
the click event of that button you can have the asp.net account read the
resume and write to the web page, e.g.
Response.Clear();
Response.ContentType = "application/vnd.ms-word";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=test.doc");
Response.WriteFile (@"c:\Resumes\myresume.doc");
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Ibrahim." wrote: Quote:
Hello,
>
How can I access a Shared Folder of the Server by using the following control.
>
1. I need to download files from c:\resumes folde by using the following;
>
<asp:HyperLink
NavigateUrl='<%#DataBinder.Eval(Container.DataItem ,"FilePath") %>'
>
a. FilePath is a database field holding the value "c:\resumes\myresume.doc"
>
b. NavigateUrl will prefix the virtual path & then the filepath.
>
Any thoughts are welcome
>
>
| | | | re: Access to Shared folder from asp.net
Hi,
Thanks a lot for your reply.
Yes, your solutions works fine, but going futher How can I dynamically send
the full file name(with the path) to the click event of LinkButton.
My case is that the file names are programatically read from the repository
& binded to the Linkbutton, so upon the click event the associated files
names are downloaded..isnt?
Thanks,
"Phillip Williams" wrote: Quote:
Instead of using a Hyperlink that directly links to the shared folder, use a
button (or a buttoncolumn in a datagrid). On the server side while processing
the click event of that button you can have the asp.net account read the
resume and write to the web page, e.g.
>
Response.Clear();
Response.ContentType = "application/vnd.ms-word";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=test.doc");
Response.WriteFile (@"c:\Resumes\myresume.doc");
>
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
>
>
"Ibrahim." wrote:
> Quote:
Hello,
How can I access a Shared Folder of the Server by using the following control.
1. I need to download files from c:\resumes folde by using the following;
<asp:HyperLink
NavigateUrl='<%#DataBinder.Eval(Container.DataItem ,"FilePath") %>'
a. FilePath is a database field holding the value "c:\resumes\myresume.doc"
b. NavigateUrl will prefix the virtual path & then the filepath.
Any thoughts are welcome | | | | re: Access to Shared folder from asp.net
Hi Ibrahim,
The LinkButton allows you to use a CommandArgument, e.g.
<ItemTemplate>
<asp:LinkButton Runat="server" ID="lnkResume"
CommandArgument ='<%#DataBinder.Eval(Container.DataItem,"FilePath" ")%>'
CommandName ="Navigate"
Text='<%#DataBinder.Eval(Container.DataItem,"UserN ame","Resume for
{0}")%>'>
</asp:LinkButton>
</ItemTemplate>
Then while handling the ItemCommand event of the DataGrid (or the RowCommand
of the GridView) you would get the CommandArgument like this:
private void datagrid1_ItemCommand(object source, DataGridCommandEventArgs e)
{
string strLink = e.CommandArgument.ToString ();
// if strLink has only the file name without the path
// then uncomment the following line
// strLink = Server.MapPath (strLink);
Response.Clear();
Response.ContentType = "application/vnd.ms-word";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=Resume.doc");
Response.WriteFile (strLink);
}
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Ibrahim." wrote: Quote:
Hi,
>
Thanks a lot for your reply.
>
Yes, your solutions works fine, but going futher How can I dynamically send
the full file name(with the path) to the click event of LinkButton.
>
My case is that the file names are programatically read from the repository
& binded to the Linkbutton, so upon the click event the associated files
names are downloaded..isnt?
>
Thanks,
>
>
>
"Phillip Williams" wrote:
> Quote:
Instead of using a Hyperlink that directly links to the shared folder, use a
button (or a buttoncolumn in a datagrid). On the server side while processing
the click event of that button you can have the asp.net account read the
resume and write to the web page, e.g.
Response.Clear();
Response.ContentType = "application/vnd.ms-word";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=test.doc");
Response.WriteFile (@"c:\Resumes\myresume.doc");
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Ibrahim." wrote: Quote:
Hello,
>
How can I access a Shared Folder of the Server by using the following control.
>
1. I need to download files from c:\resumes folde by using the following;
>
<asp:HyperLink
NavigateUrl='<%#DataBinder.Eval(Container.DataItem ,"FilePath") %>'
>
a. FilePath is a database field holding the value "c:\resumes\myresume.doc"
>
b. NavigateUrl will prefix the virtual path & then the filepath.
>
Any thoughts are welcome
>
>
| | | | re: Access to Shared folder from asp.net
Hi Williams,
Thanks a lot for your great deal of work. I was looking for the solution who
have just provided, it really has helped.
In case I require further corresponding with you in future, how shall I get
in touch ?
Thanks once again.
"Phillip Williams" wrote: Quote:
Hi Ibrahim,
>
The LinkButton allows you to use a CommandArgument, e.g.
>
<ItemTemplate>
<asp:LinkButton Runat="server" ID="lnkResume"
CommandArgument ='<%#DataBinder.Eval(Container.DataItem,"FilePath" ")%>'
CommandName ="Navigate"
Text='<%#DataBinder.Eval(Container.DataItem,"UserN ame","Resume for
{0}")%>'>
</asp:LinkButton>
</ItemTemplate>
>
Then while handling the ItemCommand event of the DataGrid (or the RowCommand
of the GridView) you would get the CommandArgument like this:
>
private void datagrid1_ItemCommand(object source, DataGridCommandEventArgs e)
{
string strLink = e.CommandArgument.ToString ();
// if strLink has only the file name without the path
// then uncomment the following line
// strLink = Server.MapPath (strLink);
Response.Clear();
Response.ContentType = "application/vnd.ms-word";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=Resume.doc");
Response.WriteFile (strLink);
}
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
>
>
"Ibrahim." wrote:
> Quote:
Hi,
Thanks a lot for your reply.
Yes, your solutions works fine, but going futher How can I dynamically send
the full file name(with the path) to the click event of LinkButton.
My case is that the file names are programatically read from the repository
& binded to the Linkbutton, so upon the click event the associated files
names are downloaded..isnt?
Thanks,
"Phillip Williams" wrote: Quote:
Instead of using a Hyperlink that directly links to the shared folder, use a
button (or a buttoncolumn in a datagrid). On the server side while processing
the click event of that button you can have the asp.net account read the
resume and write to the web page, e.g.
>
Response.Clear();
Response.ContentType = "application/vnd.ms-word";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=test.doc");
Response.WriteFile (@"c:\Resumes\myresume.doc");
>
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
>
>
"Ibrahim." wrote:
>
Hello,
How can I access a Shared Folder of the Server by using the following control.
1. I need to download files from c:\resumes folde by using the following;
<asp:HyperLink
NavigateUrl='<%#DataBinder.Eval(Container.DataItem ,"FilePath") %>'
a. FilePath is a database field holding the value "c:\resumes\myresume.doc"
b. NavigateUrl will prefix the virtual path & then the filepath.
Any thoughts are welcome | | | | re: Access to Shared folder from asp.net
Hi Ibrahim,
You are welcome.
If you have a technical question on which you are looking for a
free-discussion then continue to post on the newsgroup and any one from the
participants on this newsgroup would answer when they have free time. For
non-technical questions, you can write directly to me on my email address (as
shown on my website).
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Ibrahim." wrote: Quote:
Hi Williams,
>
Thanks a lot for your great deal of work. I was looking for the solution who
have just provided, it really has helped.
>
In case I require further corresponding with you in future, how shall I get
in touch ?
>
Thanks once again.
>
>
>
"Phillip Williams" wrote:
> Quote:
Hi Ibrahim,
The LinkButton allows you to use a CommandArgument, e.g.
<ItemTemplate>
<asp:LinkButton Runat="server" ID="lnkResume"
CommandArgument ='<%#DataBinder.Eval(Container.DataItem,"FilePath" ")%>'
CommandName ="Navigate"
Text='<%#DataBinder.Eval(Container.DataItem,"UserN ame","Resume for
{0}")%>'>
</asp:LinkButton>
</ItemTemplate>
Then while handling the ItemCommand event of the DataGrid (or the RowCommand
of the GridView) you would get the CommandArgument like this:
private void datagrid1_ItemCommand(object source, DataGridCommandEventArgs e)
{
string strLink = e.CommandArgument.ToString ();
// if strLink has only the file name without the path
// then uncomment the following line
// strLink = Server.MapPath (strLink);
Response.Clear();
Response.ContentType = "application/vnd.ms-word";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=Resume.doc");
Response.WriteFile (strLink);
}
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Ibrahim." wrote: Quote:
Hi,
>
Thanks a lot for your reply.
>
Yes, your solutions works fine, but going futher How can I dynamically send
the full file name(with the path) to the click event of LinkButton.
>
My case is that the file names are programatically read from the repository
& binded to the Linkbutton, so upon the click event the associated files
names are downloaded..isnt?
>
Thanks,
>
>
>
"Phillip Williams" wrote:
>
Instead of using a Hyperlink that directly links to the shared folder, use a
button (or a buttoncolumn in a datagrid). On the server side while processing
the click event of that button you can have the asp.net account read the
resume and write to the web page, e.g.
Response.Clear();
Response.ContentType = "application/vnd.ms-word";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=test.doc");
Response.WriteFile (@"c:\Resumes\myresume.doc");
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Ibrahim." wrote:
Hello,
>
How can I access a Shared Folder of the Server by using the following control.
>
1. I need to download files from c:\resumes folde by using the following;
>
<asp:HyperLink
NavigateUrl='<%#DataBinder.Eval(Container.DataItem ,"FilePath") %>'
>
a. FilePath is a database field holding the value "c:\resumes\myresume.doc"
>
b. NavigateUrl will prefix the virtual path & then the filepath.
>
Any thoughts are welcome
>
>
| | | | re: Access to Shared folder from asp.net
hi,
I'm using the following code for the LINKbutton, but get file damaged error
at the client side; do i have to use proper encoding?, the file opens
correctly when i access it directly.
Dim myFileInfo As New FileInfo(sender.CommandArgument)
Dim myFilePath As String =
System.Configuration.ConfigurationManager.AppSetti ngs("UploadFolder").ToString & "\" & myFileInfo.Name
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ClearContent()
Response.ContentType = "application/pdf"
HttpContext.Current.Response.AppendHeader("content-disposition",
"attachment;filename=" & myFileInfo.Name)
Response.WriteFile(myFilePath)
Response.End()
Regards,
"Phillip Williams" wrote: Quote:
Hi Ibrahim,
>
You are welcome.
>
If you have a technical question on which you are looking for a
free-discussion then continue to post on the newsgroup and any one from the
participants on this newsgroup would answer when they have free time. For
non-technical questions, you can write directly to me on my email address (as
shown on my website).
>
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
>
>
"Ibrahim." wrote:
> Quote:
Hi Williams,
Thanks a lot for your great deal of work. I was looking for the solution who
have just provided, it really has helped.
In case I require further corresponding with you in future, how shall I get
in touch ?
Thanks once again.
"Phillip Williams" wrote: Quote:
Hi Ibrahim,
>
The LinkButton allows you to use a CommandArgument, e.g.
>
<ItemTemplate>
<asp:LinkButton Runat="server" ID="lnkResume"
CommandArgument ='<%#DataBinder.Eval(Container.DataItem,"FilePath" ")%>'
CommandName ="Navigate"
Text='<%#DataBinder.Eval(Container.DataItem,"UserN ame","Resume for
{0}")%>'>
</asp:LinkButton>
</ItemTemplate>
>
Then while handling the ItemCommand event of the DataGrid (or the RowCommand
of the GridView) you would get the CommandArgument like this:
>
private void datagrid1_ItemCommand(object source, DataGridCommandEventArgs e)
{
string strLink = e.CommandArgument.ToString ();
// if strLink has only the file name without the path
// then uncomment the following line
// strLink = Server.MapPath (strLink);
Response.Clear();
Response.ContentType = "application/vnd.ms-word";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=Resume.doc");
Response.WriteFile (strLink);
}
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
>
>
"Ibrahim." wrote:
>
Hi,
Thanks a lot for your reply.
Yes, your solutions works fine, but going futher How can I dynamically send
the full file name(with the path) to the click event of LinkButton.
My case is that the file names are programatically read from the repository
& binded to the Linkbutton, so upon the click event the associated files
names are downloaded..isnt?
Thanks,
"Phillip Williams" wrote:
Instead of using a Hyperlink that directly links to the shared folder, use a
button (or a buttoncolumn in a datagrid). On the server side while processing
the click event of that button you can have the asp.net account read the
resume and write to the web page, e.g.
>
Response.Clear();
Response.ContentType = "application/vnd.ms-word";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=test.doc");
Response.WriteFile (@"c:\Resumes\myresume.doc");
>
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
>
>
"Ibrahim." wrote:
>
Hello,
How can I access a Shared Folder of the Server by using the following control.
1. I need to download files from c:\resumes folde by using the following;
<asp:HyperLink
NavigateUrl='<%#DataBinder.Eval(Container.DataItem ,"FilePath") %>'
a. FilePath is a database field holding the value "c:\resumes\myresume.doc"
b. NavigateUrl will prefix the virtual path & then the filepath.
Any thoughts are welcome |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|