Can't write to a shared drive

T

tshad

I thought I had my program working but now that did not seem to be the case.

I am trying to write from the server to a shared drive which we have set as
an H: drive.

When I run my web page from my local machine (VS) it writes correctly to the
H: drive.

But when I run it off the Server (which also has access to the H: drive it
says it can't find it.

For example, this is the path I am trying to use to write out my csv file:

H:\SHARE\Reports

But when I try to open it I get:

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

Is there something I have to do in IIS to allow it to write to the folder?

Thanks,

Tom
 
T

tshad

Mark Rae said:
I've already explained this...

But I had already sent this before I saw your explanation.
It works on your local machine because your local machine has the shared
folder in question mapped as a network drive. To get this to work on the
webserver, you will either have to create the same mapped network share,
or reference the folder explicitly via its UNC path...

Also, as mentioned, my server has the same mapping:

H:/

Which as a folder Share which has a folder Reports.

And I access the drive like:

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

Where fileName is:

fileNameOut = @"H:\SHARE\Reports\file.csv;

So you are saying my server code should be able to write to this share as
long as the Server has access?

I just went on the Server, accessed the folder from Windows Explorer and put
a folder and a file in it and it worked fine - so the permissions are there.
H:\SHARE\Reports

Thanks,

Tom
 
P

Patrice

Hi,
Also, as mentioned, my server has the same mapping:

H:/

This is not the server this is YOUR profile. Mapped drive are tied to a
specific user profile, they are not a server wide setting. For a web
application, I would strongly recommend using UNC names
(\\servername\share\name\path\file.txt) ...
 
T

tshad

Mark Rae said:
I've already explained this...

It works on your local machine because your local machine has the shared
folder in question mapped as a network drive. To get this to work on the
webserver, you will either have to create the same mapped network share,
or reference the folder explicitly via its UNC path...
The UNC path was what I needed to do.

I hadn't realized that the Mapping I did while logged on wouldn't apply to
the website which is running as a service.

That would also explain why it works when running out of VS. In that mode,
I am logged on so the mappings would apply.

Thanks,

Tom
 
T

tshad

Patrice said:
Hi,


This is not the server this is YOUR profile. Mapped drive are tied to a
specific user profile, they are not a server wide setting. For a web
application, I would strongly recommend using UNC names
(\\servername\share\name\path\file.txt) ...
That was it. Mark had also mention it but I hadn't tried it yet. I tried
the first thing he mentioned which was creating the mapped share on the
server.

That actually makes sense now that I look at it.

Works perfectly now on my server.

So, just out of curiosity, how would you map a drive for the server (not
that I would, just curious) - or can you.

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,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top