CynergySoftware
asked on
access denied on copying files?
ok i am trying to copy a file here from a local source to a remote source
I have verifed i have permission and from the local source i can manually copy files into the directory on the remote source
here is the code
try
{
int debug = (int) clsLogManager.clsLogger.Lo ggingLevel .DEBUG;
log.WriteToLog(debug, "Attempting to copy local file to remote server");
FileInfo local = new FileInfo(localPath+fileNam e);
log.WriteToLog(debug, "Local Path:"+localPath+fileName) ;
FileInfo mapped = new FileInfo(sharedPath+fileNa me);
log.WriteToLog(debug, "Remote Path:"+sharedPath+fileName );
if(local.Exists)
{
log.WriteToLog(debug, "Local File Exists");
local.CopyTo(sharedPath+fi leName,tru e);
log.WriteToLog(debug, "Copy successful");
}
else
{
log.WriteToLog(debug, "Local file does not exist");
}
}
catch(Exception ex)
{
log.WriteToLog((int) clsLogManager.clsLogger.Lo ggingLevel .EXCEPTION , ex.Message);
}
Now here is the log data with the error message
Attempting to copy local file to remote server
DEBUG: -- 5/27/2006 3:24:43 PM -- Local Path:C:\NetShare\Dialer\Vo iceFiles\1 345216470. wav
DEBUG: -- 5/27/2006 3:24:43 PM -- Remote Path:\\<server name>\Dialer\VoiceFiles\13 45216470.w av
DEBUG: -- 5/27/2006 3:24:43 PM -- Local File Exists
EXCEPTION -- 5/27/2006 3:24:43 PM -- Access to the path "\\<server name>\Dialer\VoiceFiles\13 45216470.w av" is denied.
like I said i can do this fine by browsing to the remote directory and copying files to it.
any ideas?
I have masked the ip address for obvisous reasons =)
I have verifed i have permission and from the local source i can manually copy files into the directory on the remote source
here is the code
try
{
int debug = (int) clsLogManager.clsLogger.Lo
log.WriteToLog(debug, "Attempting to copy local file to remote server");
FileInfo local = new FileInfo(localPath+fileNam
log.WriteToLog(debug, "Local Path:"+localPath+fileName)
FileInfo mapped = new FileInfo(sharedPath+fileNa
log.WriteToLog(debug, "Remote Path:"+sharedPath+fileName
if(local.Exists)
{
log.WriteToLog(debug, "Local File Exists");
local.CopyTo(sharedPath+fi
log.WriteToLog(debug, "Copy successful");
}
else
{
log.WriteToLog(debug, "Local file does not exist");
}
}
catch(Exception ex)
{
log.WriteToLog((int) clsLogManager.clsLogger.Lo
}
Now here is the log data with the error message
Attempting to copy local file to remote server
DEBUG: -- 5/27/2006 3:24:43 PM -- Local Path:C:\NetShare\Dialer\Vo
DEBUG: -- 5/27/2006 3:24:43 PM -- Remote Path:\\<server name>\Dialer\VoiceFiles\13
DEBUG: -- 5/27/2006 3:24:43 PM -- Local File Exists
EXCEPTION -- 5/27/2006 3:24:43 PM -- Access to the path "\\<server name>\Dialer\VoiceFiles\13
like I said i can do this fine by browsing to the remote directory and copying files to it.
any ideas?
I have masked the ip address for obvisous reasons =)
ASKER
yes from the command prompt i can manually type the copy
copy C:\NetShare\Dialer\VoiceFi les\134521 6470.wav \\<Server Name>\Dialer\VoiceFiles\13 45216470.w av
and it copies just fine
copy C:\NetShare\Dialer\VoiceFi
and it copies just fine
This is a Winforms app, right? The program is running using your credentials?
Is your app running as a normal application (or some other type i.e. windows service, asp.net, webservice, etc) where it might be running as another user?
ASKER
yes it is a windows application
and it is running as the same user that i went through command prompt with
and it is running as the same user that i went through command prompt with
OK, you're really gonna think I'm nuts, but does the file already exist? You could add the second parameter to the CopyTo call...
Arghh... Pulease ignore that last burst of static... <sigh>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok it seem the file was in use... so instead of trying to copy it right after it gets created. I am threading out a FileSystemWatch object. and that monitors the folder and copies new and updated files to the remote server as needed. It checks to see if in use. If it is then it sleeps a few seconds and tried again.
anyoneis you reply helped me get to this so awarding points to you....thanks
anyoneis you reply helped me get to this so awarding points to you....thanks
Thanks for the points! And more importantly, thanks for filling the rest of us in on what you found! I used exactly the same technique in a DirectorySweep program I wrote.
David
David
Can you perform the copy by going to a cmd prompt and doing a copy?
Grasping at straws here :-)
David