473,804 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:HyperLin k
NavigateUrl='<% #DataBinder.Eva l(Container.Dat aItem,"FilePath ") %>'

a. FilePath is a database field holding the value "c:\resumes\myr esume.doc"

b. NavigateUrl will prefix the virtual path & then the filepath.

Any thoughts are welcome
Jul 6 '06 #1
7 4039
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:HyperLin k
NavigateUrl='<% #DataBinder.Eva l(Container.Dat aItem,"FilePath ") %>'

a. FilePath is a database field holding the value "c:\resumes\myr esume.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.Conten tType = "applicatio n/vnd.ms-word";
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename=test.doc" );
Response.WriteF ile (@"c:\Resumes\m yresume.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:HyperLin k
NavigateUrl='<% #DataBinder.Eva l(Container.Dat aItem,"FilePath ") %>'

a. FilePath is a database field holding the value "c:\resumes\myr esume.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..isn t?

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.Conten tType = "applicatio n/vnd.ms-word";
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename=test.doc" );
Response.WriteF ile (@"c:\Resumes\m yresume.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:HyperLin k
NavigateUrl='<% #DataBinder.Eva l(Container.Dat aItem,"FilePath ") %>'

a. FilePath is a database field holding the value "c:\resumes\myr esume.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:LinkButt on Runat="server" ID="lnkResume"
CommandArgument ='<%#DataBinder .Eval(Container .DataItem,"File Path"")%>'
CommandName ="Navigate"
Text='<%#DataBi nder.Eval(Conta iner.DataItem," UserName","Resu me 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_ItemC ommand(object source, DataGridCommand EventArgs e)
{
string strLink = e.CommandArgume nt.ToString ();
// if strLink has only the file name without the path
// then uncomment the following line
// strLink = Server.MapPath (strLink);
Response.Clear( );
Response.Conten tType = "applicatio n/vnd.ms-word";
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename=Resume.do c");
Response.WriteF ile (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..isn t?

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.Conten tType = "applicatio n/vnd.ms-word";
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename=test.doc" );
Response.WriteF ile (@"c:\Resumes\m yresume.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:HyperLin k
NavigateUrl='<% #DataBinder.Eva l(Container.Dat aItem,"FilePath ") %>'
>
a. FilePath is a database field holding the value "c:\resumes\myr esume.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:LinkButt on Runat="server" ID="lnkResume"
CommandArgument ='<%#DataBinder .Eval(Container .DataItem,"File Path"")%>'
CommandName ="Navigate"
Text='<%#DataBi nder.Eval(Conta iner.DataItem," UserName","Resu me 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_ItemC ommand(object source, DataGridCommand EventArgs e)
{
string strLink = e.CommandArgume nt.ToString ();
// if strLink has only the file name without the path
// then uncomment the following line
// strLink = Server.MapPath (strLink);
Response.Clear( );
Response.Conten tType = "applicatio n/vnd.ms-word";
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename=Resume.do c");
Response.WriteF ile (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..isn t?

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.Conten tType = "applicatio n/vnd.ms-word";
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename=test.doc" );
Response.WriteF ile (@"c:\Resumes\m yresume.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:HyperLin k
NavigateUrl='<% #DataBinder.Eva l(Container.Dat aItem,"FilePath ") %>'

a. FilePath is a database field holding the value "c:\resumes\myr esume.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:LinkButt on Runat="server" ID="lnkResume"
CommandArgument ='<%#DataBinder .Eval(Container .DataItem,"File Path"")%>'
CommandName ="Navigate"
Text='<%#DataBi nder.Eval(Conta iner.DataItem," UserName","Resu me 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_ItemC ommand(object source, DataGridCommand EventArgs e)
{
string strLink = e.CommandArgume nt.ToString ();
// if strLink has only the file name without the path
// then uncomment the following line
// strLink = Server.MapPath (strLink);
Response.Clear( );
Response.Conten tType = "applicatio n/vnd.ms-word";
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename=Resume.do c");
Response.WriteF ile (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..isn t?
>
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.Conten tType = "applicatio n/vnd.ms-word";
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename=test.doc" );
Response.WriteF ile (@"c:\Resumes\m yresume.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:HyperLin k
NavigateUrl='<% #DataBinder.Eva l(Container.Dat aItem,"FilePath ") %>'
>
a. FilePath is a database field holding the value "c:\resumes\myr esume.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 .CommandArgumen t)
Dim myFilePath As String =
System.Configur ation.Configura tionManager.App Settings("Uploa dFolder").ToStr ing & "\" & myFileInfo.Name
HttpContext.Cur rent.Response.C lear()
HttpContext.Cur rent.Response.C learHeaders()
HttpContext.Cur rent.Response.C learContent()

Response.Conten tType = "applicatio n/pdf"
HttpContext.Cur rent.Response.A ppendHeader("co ntent-disposition",
"attachment;fil ename=" & myFileInfo.Name )
Response.WriteF ile(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:LinkButt on Runat="server" ID="lnkResume"
CommandArgument ='<%#DataBinder .Eval(Container .DataItem,"File Path"")%>'
CommandName ="Navigate"
Text='<%#DataBi nder.Eval(Conta iner.DataItem," UserName","Resu me 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_ItemC ommand(object source, DataGridCommand EventArgs e)
{
string strLink = e.CommandArgume nt.ToString ();
// if strLink has only the file name without the path
// then uncomment the following line
// strLink = Server.MapPath (strLink);
Response.Clear( );
Response.Conten tType = "applicatio n/vnd.ms-word";
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename=Resume.do c");
Response.WriteF ile (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..isn t?

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.Conten tType = "applicatio n/vnd.ms-word";
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename=test.doc" );
Response.WriteF ile (@"c:\Resumes\m yresume.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:HyperLin k
NavigateUrl='<% #DataBinder.Eva l(Container.Dat aItem,"FilePath ") %>'

a. FilePath is a database field holding the value "c:\resumes\myr esume.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
2491
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 folder. -- 5khzgjf9e001@sneakemail.com
5
3701
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. Following problems occur: 1. Access is way too slow in WAN environment. Server is located in New Jersey and users are in California and Puerto Rico. 2. Database often becomes corrupt 3. When one user updates some data in the database, other users...
8
4875
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 users on LAN, BE on shared server. Each user has own FE to allow special report & query creation, each user has common forms for input and edit of main table data, Main data tables are linked from BE, special tables are stored in users FE. ...
2
2156
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 users to upload images (screen captures for fault reporting). These files get saved in the folder www.<domain>.co.uk/uploadedfiles/<filename>. I want to prevent public users from being able to see these uploaded files but I want to provide an...
17
3159
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 - Access 2000; folder with back-ends for both computers and 'Update' folder. I have a launcher program that launces my application (MyApp). The launcher program also checks for updates to MyApp located in 'Update' folder (on
13
2300
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 protection (I heard people say that I should buy a dedicated server or have special rights for each and every user, but I can keep it simple since there will be no intruders - no internet connection available -). I don't think that the "Programs"...
7
4750
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 allowed Full Control permission on abc.txt on the other machine. any idea? thanks,
0
2642
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 first place. We have a .NET application that read/writes files to a shared folder. It doesn't use a mapped drive, so it accesses the folder using the \\hostname "scheme". I've read that the .NET application should run as a domain user in order to...
25
3019
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 PC running Microsoft Windows XP Professional 5.1.2600 (SP2) A PC running Microsoft Windows XP Professional 5.1.2600 (SP2) All of the PCs are running IIS
3
2179
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 a linked MDE front end. The MDB back end is in a shared folder, however, on switching PC 2 on and signing into the database error message 3051 is displayed: "The Microsoft Jet database ebgine cannot open the file ... It is already open exculsively by...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10352
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10097
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7642
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5535
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.