Click here to Skip to main content
Rate this: bad
good
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\\";
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: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 20:48pm

1 solution

Rate this: bad
good
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:
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. Smile | :)
 
—SA
  Permalink  
v2
Comments
Kunal Ved at 25-Nov-13 3:39am
   
I meant I need to share the uploaded files between two websites within the same serverspace.
Sergey Alexandrovich Kryukov at 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)

  Print Answers RSS
0 OriginalGriff 505
1 Maciej Los 325
2 Richard MacCutchan 265
3 Mathew Soji 220
4 BillWoodruff 210
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 25 Nov 2013
Copyright © CodeProject, 1999-2014
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