Solved

Could not find a part of the path - error when attempting to write a file to a shared drive

Posted on 2008-06-19
2
1,541 Views
Last Modified: 2012-08-13
Experts,  I see quite a bit has been written on this.. and I even saw what appeared to be a perfect post on the internet for my problem.. but it did not resolve it.....

problem:
in a web .net environment.. vb.net  I am writing a file to a directory specified by the user... if the directory exists on the web server... then no problem the file can be written..

but if the directory is a shared drive (shared on the server.. NOT a the users share)  we get the error "could not find a part of the path".

There is a good article on the interrnet about how remote server doesn't know the user.... so we did the following
1) found the web user  "iusr_california"  on the web server
2) added that user on the remote machine
3) added that user to permissions on the shared directory.. gave the user full access
4) even made sure the password for the user on both machines was the same.
5)  then we used the path:   111.11.11.1111\sharedrivename\  as the write to directory..

now we get the error  access denied....  even allowed "everyone" access to directory on the remote server and still results in access denied when we try to write to the directory on the shared drive.

 this server (server 2005)  operating system server 2003.... using vs 2005....

I saw a lengthy article about a similar problem when running a service.. but that is not our environment.

this is a gui web application where user gets to pick the location he writes file to...

I am beginning to think it would be easier to write a simple batch program that moves the files from the web server to the target server.. since this does not change very often for the customer

thanks.
0
Comment
Question by:rhoss
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
athapa earned 250 total points
ID: 21829691
Try impersonating another user who has rights to that file server instead.  I'm not sure if the newer framework includes these but in the past I had to use pinvoke.

Here are some discussions which deals with similar question.
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_23154081.html
http://www.codeproject.com/KB/cs/zetaimpersonator.aspx

Whenever you need to access resources which only another user can access,
1. call LogonUser
2. perform your task
3. call RevertToSelf to rollback impersonation
0
 

Author Closing Comment

by:rhoss
ID: 31469000
thanks... I am more comfortable in vb.net so found a similar article with vb.net impersonation...

I'll try it... if I don't write back it worked....  but makes senses.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question