PC Review


Reply
Thread Tools Rate Thread

Can't write to a shared drive

 
 
tshad
Guest
Posts: n/a
 
      31st Oct 2009
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


 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      31st Oct 2009

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "tshad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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.

>
> 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

>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      1st Nov 2009
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) ...

--
Patrice

 
Reply With Quote
 
tshad
Guest
Posts: n/a
 
      1st Nov 2009

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "tshad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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.

>
> 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

>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
tshad
Guest
Posts: n/a
 
      1st Nov 2009

"Patrice" <http://scribe-en.blogspot.com/> wrote in message
news:%(E-Mail Removed)...
> 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) ...
>

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

> --
> Patrice
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot write to a shared drive John Smith Windows XP Help 5 28th Nov 2008 06:06 PM
Can't push to shared/write access shared drive msnews.microsoft.com Windows XP Networking 5 28th Feb 2008 12:40 PM
Backup app can't write to shared drive Nick Windows XP General 9 21st Jun 2007 10:09 AM
How can I write to a shared drive on another server =?Utf-8?B?UnVlcGVu?= Microsoft C# .NET 3 13th Oct 2005 11:39 PM
when i use stream writer to write to a shared folder, and the network card of that remote computer is disabled in the middle of the write Daniel Microsoft Dot NET Framework 0 8th Sep 2005 01:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:44 PM.