Open a file on a share from web page

Discussion in 'ASP .Net' started by tshad, Oct 31, 2009.

  1. tshad

    tshad Guest

    I have a file I just wrote out to a share from my web page and I want to be
    able to open it on my local machine in excel (it is a csv file).

    Can I do that from a link?

    Thanks,

    Tom
     
    tshad, Oct 31, 2009
    #1
    1. Advertising

  2. tshad

    tshad Guest

    Nevermind, I got it.

    <a file://H:\fileName>fileName</a>

    Tom

    "tshad" <> wrote in message
    news:...
    >I have a file I just wrote out to a share from my web page and I want to be
    >able to open it on my local machine in excel (it is a csv file).
    >
    > Can I do that from a link?
    >
    > Thanks,
    >
    > Tom
    >
     
    tshad, Oct 31, 2009
    #2
    1. Advertising

  3. tshad

    tshad Guest

    "Mark Rae [MVP]" <> wrote in message
    news:esw%...
    > "tshad" <> wrote in message
    > news:...
    >
    >> Nevermind, I got it.
    >>
    >> <a file://H:\fileName>fileName</a>

    >
    > Forget that completely. It only works on your machine because your machine
    > has a drive mapping to the server share.
    >


    But the server where IIS is located also has the same share set up as H:
    (all the machines have it set up this way).

    > If you absolutely need to use remote resources, then you will need to open
    > them with the System.IO namespace and then stream them to the client via a
    > MIME type which the client browser will understand...
    >


    How would I do that?

    At the moment, my code does:

    fs = new FileStream(fileName, FileMode.Create,
    FileAccess.ReadWrite);
    csvFileWriter = new StreamWriter(fs);

    Where fileName is:

    fileNameOut = @"H:\SHARE\Reports\" +
    Path.GetFileNameWithoutExtension(((Label)GridView1.Rows[1].FindControl("lblFileName")).Text)
    +
    "_Discrepancies.csv";

    You are saying I can't do this, right?

    H:\SHARE is acessible to all the company and all have read and write
    permission.

    So how would I change this to do the MIME business?

    What about putting the folder inside the web app?

    Would that work?

    What about accessing the file from the Share (if I could write to it). I
    did that to solve the SaveFileDialog problem where I would click the link
    and it would allow me to open it (via excel) or save it to my system using
    the following as my link:

    <a
    href=file:///H:/SHARE/Reports/148_010309_033109_Discrep.csv>148_010309_033109_Discrep.csv</a>

    Again this works fin from my machine.

    Thanks,

    Tom

    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    tshad, Oct 31, 2009
    #3
  4. tshad

    tshad Guest

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "tshad" <> wrote in message
    > news:%...
    >
    >> You are saying I can't do this, right?

    >
    > You're the one who's saying it doesn't work!
    >

    I am saying I can't get it to work on my server.

    > When you step through the code, how far does it get...?


    I can't really step through the code on the server as I don't have VS there.

    In your earlier post you said:

    If you absolutely need to use remote resources, then you will need to open
    them with the System.IO namespace and then stream them to the client via a
    MIME type which the client browser will understand

    Wasn't that what I was using when I did:

    fs = new FileStream(fileName, FileMode.Create,
    FileAccess.ReadWrite);
    csvFileWriter = new StreamWriter(fs);

    You asked how far I got - I got to the FileStream, I believe since the
    message said:

    Could not find a part of the path
    'H:\SHARE\Reports\043_051909_083109_Discrepancies.csv'.

    >
    >> Again this works fine from my machine.

    >
    > True but irrelevant since your machine isn't the webserver...
    >

    Maybe not, but wouldn't my machine have the same problem since it is
    pointing at the same share?

    Thanks,

    Tom
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    tshad, Nov 1, 2009
    #4
  5. tshad

    tshad Guest

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "tshad" <> wrote in message
    > news:...
    >
    >>>> Again this works fine from my machine.
    >>>
    >>> True but irrelevant since your machine isn't the webserver...
    >>>

    >> Maybe not, but wouldn't my machine have the same problem since it is
    >> pointing at the same share?

    >
    >
    > Absolutely not! The default account under which ASP.NET runs almost
    > certainly has no permission to access anything outside its own virtual
    > directory...
    >

    That makes sense and as we talked in the other post that the problem was
    that the mapped drive won't work for the IIS service as the mappings I have
    on my machine (or that I set up on the server under my account) won't apply.

    Thanks,

    Tom
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    tshad, Nov 1, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. P4trykx

    C# open file on windows share

    P4trykx, Aug 7, 2007, in forum: ASP .Net
    Replies:
    8
    Views:
    17,446
    P4trykx
    Aug 8, 2007
  2. Alex
    Replies:
    1
    Views:
    178
    Bob Barrows
    Jun 30, 2003
  3. Saraswati lakki
    Replies:
    0
    Views:
    1,426
    Saraswati lakki
    Jan 6, 2012
  4. Jack
    Replies:
    2
    Views:
    246
  5. Eric Wong
    Replies:
    0
    Views:
    226
    Eric Wong
    Feb 13, 2010
Loading...

Share This Page