Click here to Skip to main content
15,886,071 members
Please Sign up or sign in to vote.
1.00/5 (1 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

C#
if (fileUpTimeTable.HasFile)
{
    string TimeTableFileName = fileUpTimeTable.FileName;
    string TimeTableFilepath = "D:\\My_Drive\\Kunal_backup\\Kunal\\StudentDesk_aarti\\StudentDeskv2\\Download\\TimeTable\\";
fileUpTimeTable.SaveAs(TimeTableFilepath+fileUpTimeTable.FileName);
FillGrid();
}


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
FILEPATH --
D:\My_Drive\Kunal_backup\Kunal\StudentDesk_aarti\StudentDeskv2\Download\TimeTable\abc.pdf


Please guide me how can I accomplish the same




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

1 solution

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:
http://msdn.microsoft.com/en-us/library/ms524632%28v=vs.90%29.aspx[^].

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: http://en.wikipedia.org/wiki/Hard_link[^].

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

—SA
 
Share this answer
 
v2
Comments
Kunal Ved 25-Nov-13 3:39am    
I meant I need to share the uploaded files between two websites within the same serverspace.
Sergey Alexandrovich Kryukov 25-Nov-13 3:52am    
I already answered assuming this problem, it third and fourth paragraph. Agree?
—SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900