473,322 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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
Jul 6 '06 #1
7 4010
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

Jul 6 '06 #2
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

Jul 6 '06 #3
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
Jul 7 '06 #4
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
>
>
Jul 7 '06 #5
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
Jul 7 '06 #6
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
>
>
Jul 7 '06 #7
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
Aug 8 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James | last post by:
how can i allow access to a shared network folder? i am trying to give access to my as pages only. i don't want just anyone to type in the path of my files. i can't seem to do this with a shared...
5
by: premmehrotra | last post by:
I currently have a multi-user access database which is put on a shared drive L: on a Windows Servers. Entire database is one file premdb.mdb. Users access this database from their laptops....
8
by: Thats Me | last post by:
Background: Access 2000 running on Windows 2000, Did not design inherited (three previous database maintainers in last 18 months), Non-existent comments for existing code modules and objects, six...
2
by: Ian B | last post by:
This is a basic question for anyone who knows what they're doing with web server admin so hopefully someone will be able to assist me here!... I have a www based asp.net application which allows...
17
by: rdemyan via AccessMonster.com | last post by:
With A2003, I'm having trouble accessing files in a folder on another computer where back-end files, update files, etc are located. Here's the scenario: 1) Computer #1 - A2003 2) Computer #2 -...
13
by: Elton Cohen | last post by:
Hi newsgroup! Can anyone tell me where I should put a simple Access database file in order to be accessible for every computer in the network (same workgroup)? There does not need to be any...
7
by: Speech Lover | last post by:
I have problem writing content to a UNC file from my ASP.NET 1.1 application. This is on Windows server 2003 The event log says "X:\temp\abc.txt path not found" and stuff. Note that I have...
0
Pittaman
by: Pittaman | last post by:
Hello, I've searched the net (and this site in particular) but haven't found anything useful yet. I guess this could be a .NET question too, but I believe it's a windows permissions question in the...
25
by: p byers | last post by:
Good Morning Folks I have a LAN Among the several connections to it are the following four devices: A MAXSTOR network Storage Device A PC running Microsoft Windows 2000 Server 5.0.2195 (SP4) A...
3
by: noseyneil | last post by:
I have a MS Access 2000 database running my wife's cross stitch business. We have it on two PCs both running XP, with one having a linked mde APP front end (PC 2) and one having the MDB back end and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.