moving a file on a remote server

  • Thread starter Thread starter i. Wiin
  • Start date Start date
I

i. Wiin

Below is my code. I'm trying to copy a log file from one location to
another as illustrated below. I'm always getting to the portion of "File
Does Not Exist". I'm running the code from a web server on \\peanuts. If I
type the "path" into Windows Explorer's address bar, then I can get the
file, so I know I have access to it...but for some reason the web page
thinks the file does not exist.

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string path = @"\\hotdogs\WebLogs\ex040529.log";
string pathto = @"\\hotdogs\WebLogs\Old\ex040529.log";
if (File.Exists( path ))
{
File.Copy(path,pathto,true);
this.TextBox1.Text = "Copied.";
}
else
this.TextBox1.Text = "File Does Not Exist.";
}
 
The ASPNET user account that ASP.NET uses by default does not have network
permissions. Either give the account such network permissions (likely with
the help of your network administrator) or use impersonation to have it run
under a different user account that does have such permissions.
For testing purposes you can have it run under your personal user account.
Here's more info:
http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconaspnetimpersonation.asp
 
Interesting....

I've set impersonataion to a network user who has access to the remote
share. I've added the following to the system.web section of the Web.config
file:
<identity impersonate="true" userName="domain\username"
password="password"/>

Now, it seems to have problems now on my LOCAL machine running the
application. I get the following error...

Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary
ASP.NET Files\logreports\9e2e99c4\1f26e007\hash.web" is denied.
 
Well of course you need to use a user acount that has permissions to every
folder that needs to be accessed.
It seems like you should add the user to your Temporary ASP.NET files
directory and give it significant privileges.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
 

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

Back
Top