I all,
i've write a sample ftp Windows service which download files and copy them on remote share or remote mapped drive (the service works fine on local drives).
This part of code is the function to change the local path for downloaded files.
If the configured path is different from local drive C: the new path is selected.
The program works fine in debug or release mode into Visual Studio. All downloaded files were placed on remote share or remote mapped drive.
On Installed Service the SetCurrentDirec tory(...) eg.. 'H:\' which is on remote server fall in an Exception. Same if the directory is a remote unc path like '\\server\root' .
I tried to install the service like System Account, Network Account or User Account granted to shares, but the SetCurrentDirec tory fall always in an Exception.
Anybody has an idea how can i resolve this issue?
Thanks.
Max
CODE -----------------------------------------------------------------------------------------------
public void chlocaldir(stri ng dirName)
{
string drive = dirName.Remove( 1,dirName.Lengt h-1);
string path = dirName.Remove( 0,2);
try
{
if ( drive != "C")
{
// Change Drive
Directory.SetCu rrentDirectory( drive + ":\\");
// Change Path
Directory.SetCu rrentDirectory( drive + ":" + path);
}
else
Directory.SetCu rrentDirectory( drive + ":" + path);
}
catch(Exception e)
{
Directory.SetCu rrentDirectory( "C:\\");
throw new IOException("Ca n't connect to Remote Drive: " + e.Message);
}
this.localPath = drive + ":" + path;
}
CODE ------------------------------------------------------------------------------------------------
From: Max Baki
email: mb*@email.it
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>vYfZDKECAU2 njkPvbIpjlA==</Id>