Open a file on a share from web page

T

tshad

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
 
T

tshad

Mark Rae said:
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
 
T

tshad

Mark Rae said:
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'.
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
 
T

tshad

Mark Rae said:
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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top