Access to Shared folder from

Discussion in 'ASP .Net' started by Guest, Jul 6, 2006.

  1. Guest

    Guest Guest


    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;

    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
    Guest, Jul 6, 2006
    1. Advertisements

  2. Guest

    Guest Guest

    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...
    Guest, Jul 6, 2006
    1. Advertisements

  3. Guest

    Guest Guest

    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 account read the
    resume and write to the web page, e.g.

    Response.ContentType = "application/";
    Response.WriteFile (@"c:\Resumes\myresume.doc");
    Guest, Jul 6, 2006
  4. Guest

    Guest Guest


    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?

    Guest, Jul 7, 2006
  5. Guest

    Guest Guest

    Hi Ibrahim,

    The LinkButton allows you to use a CommandArgument, e.g.

    <asp:LinkButton Runat="server" ID="lnkResume"
    CommandArgument ='<%#DataBinder.Eval(Container.DataItem,"FilePath"")%>'
    CommandName ="Navigate"
    Text='<%#DataBinder.Eval(Container.DataItem,"UserName","Resume for

    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.ContentType = "application/";
    Response.WriteFile (strLink);
    Guest, Jul 7, 2006
  6. Guest

    Guest Guest

    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.
    Guest, Jul 7, 2006
  7. Guest

    Guest Guest

    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).
    Guest, Jul 7, 2006
  8. Guest

    Guest Guest


    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.AppSettings("UploadFolder").ToString & "\" & myFileInfo.Name

    Response.ContentType = "application/pdf"
    "attachment;filename=" & myFileInfo.Name)

    Guest, Aug 8, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.