Click here to Skip to main content
13,000,636 members (53,625 online)
Rate this:
Please Sign up or sign in to vote.
I want to set a download link in my gridview , the thing is that I have set a physical path while Uploading the file and saving the file name and its pyshical path in the database

if (fileUpTimeTable.HasFile)
    string TimeTableFileName = fileUpTimeTable.FileName;
    string TimeTableFilepath = "D:\\My_Drive\\Kunal_backup\\Kunal\\StudentDesk_aarti\\StudentDeskv2\\Download\\TimeTable\\";

The Uploading works fine and the file and its filepath gets saved in the database successfully.
The gridview also shows the correct data but I am not able to download the uploaded file from the gridview

Following are Database fields
ID --Pkey
FILENAME -- e.g abc.pdf

Please guide me how can I accomplish the same

<asp:HyperLinkField DataNavigateUrlFields="FILENAME" DataNavigateUrlFormatString="{0}"
                            Text="&lt;img src='../IMAGES/download.jpg' style='border:none'&gt;" HeaderText="Download" Target="_blank"/>

P.S : I am not using Virtual path , but Physical because I need to share these uploaded file between two different Project Solutions
Posted 24-Nov-13 19:48pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

A Web site has nothing to do with "Project Solutions" (what is it, by the way?). Project and solutions are just the artifact of development, they don't exist after you deploy the site code. The thing is: yes, the code-behind code needs what you call "physical paths"; more exactly, file path names in terms of the server's host file system. Such path names are obtained using the method MapPath:[^].

As to the sharing some files between-who-knows-what, you can do whatever you want, with one important limitation: usually, the Web applications are executed by the HTTP server software is some sandboxed environment. It won't allow access to to any files except those placed under the directory which is set up as a root directory for your site.

If you want to share some files between too different sites served up in the same host, without overlapping of the file paths, sharing the files is rather difficult. First work-around which comes to my mind would be the use of hard links (don't mix them up with .lnk files; nothing in common). Please see:[^].

If this is the case, it's better to avoid such difficulties. For example, you can always formally merge too formerly different sites, as soon as you serve them up on the same host. As you did not clearly explain your sharing problem, I think this would be enough for now. :-)

Kunal Ved 25-Nov-13 3:39am
I meant I need to share the uploaded files between two websites within the same serverspace.
I already answered assuming this problem, it third and fourth paragraph. Agree?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 25 Nov 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100