Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Access to Shared folder from asp.net

Reply
Thread Tools

Access to Shared folder from asp.net

 
 
=?Utf-8?B?SWJyYWhpbS4=?=
Guest
Posts: n/a
 
      07-06-2006
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=
Guest
Posts: n/a
 
      07-06-2006
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:

> 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
>
>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      07-06-2006
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
>
>

 
Reply With Quote
 
=?Utf-8?B?SWJyYWhpbS4=?=
Guest
Posts: n/a
 
      07-07-2006
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
> >
> >

 
Reply With Quote
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      07-07-2006
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
> > >
> > >

 
Reply With Quote
 
=?Utf-8?B?SWJyYWhpbS4=?=
Guest
Posts: n/a
 
      07-07-2006
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:

> 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
> > > >
> > > >

 
Reply With Quote
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      07-07-2006
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:

> 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:
>
> > 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
> > > > >
> > > > >

 
Reply With Quote
 
=?Utf-8?B?SWJyYWhpbS4=?=
Guest
Posts: n/a
 
      08-08-2006
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:

> 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:
>
> > 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:
> >
> > > 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
> > > > > >
> > > > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fix folder picture in a shared folder across network Talista Computer Support 1 01-23-2009 07:53 PM
SOLVED - windows xp rename folder within shared folder, notrefreshing window jameshanley39@yahoo.co.uk Computer Information 0 07-30-2008 06:33 PM
How to Access my Shared Folder document after disabling File Shari =?Utf-8?B?TWlrZQ==?= Wireless Networking 3 03-21-2006 12:26 AM
Cannot view/access new laptop shared folder on network T5 Wireless Networking 3 03-20-2006 08:52 PM
I can see the shared folder but can't access it =?Utf-8?B?c2FyYWZpbmE2Mw==?= Wireless Networking 1 02-03-2006 05:22 PM



Advertisments