473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

FTP loading in Windows Service

I will try to explain the problem.
I'm doing an asynchronous copy file from local station to my FTP according
to the MSDN example:
http://msdn2.microsoft.com/en-us/lib...st(VS.80).aspx

see the 3-rd example ("The following code example demonstrates using
asynchronous operations to upload a file to an FTP server.")

In the main part of my service I use System.Threading.Timer.

After files copied they should be moved from one folder to another.

But the system crashes after files copied to FTP when I try any operation
with file which is already sent to ftp.
So, it's blocked, locked or whatever.

I close all streams and tried stream.Lock/Unlock.

But still the problem exists.

When I place the same code, with the same Threading Timer inside non-service
project, just WinForm, it works fine, but under the Service doesn't.

Could you give me any clue, please?

Sep 25 '07 #1
4 5583
Robert,

Well, you didn't show any code, and you didn't show any details of the
exception. Could you provide some of those? It would help.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Robert" <Ro****@discussions.microsoft.comwrote in message
news:46**********************************@microsof t.com...
>I will try to explain the problem.
I'm doing an asynchronous copy file from local station to my FTP according
to the MSDN example:
http://msdn2.microsoft.com/en-us/lib...st(VS.80).aspx

see the 3-rd example ("The following code example demonstrates using
asynchronous operations to upload a file to an FTP server.")

In the main part of my service I use System.Threading.Timer.

After files copied they should be moved from one folder to another.

But the system crashes after files copied to FTP when I try any operation
with file which is already sent to ftp.
So, it's blocked, locked or whatever.

I close all streams and tried stream.Lock/Unlock.

But still the problem exists.

When I place the same code, with the same Threading Timer inside
non-service
project, just WinForm, it works fine, but under the Service doesn't.

Could you give me any clue, please?

Sep 25 '07 #2
Nicolas,
The exception is:
UnauthorizedAccessException

Timer in the main service body is from System.Threading library.

The example link I mentioned is the code.

Inside timer callback after files transfered I just move files from Folder1
to Folder2.

The FTP transfer goes fast, actually there are just 2 files only for now.

I can see them inside remote folder... but Ftp request blocks them only if I
use this code inside service.

As I mentioned before if placed in standalone aplication - works fine.
Sep 25 '07 #3
Services by default run under account credentials that are not highly
privileged. You can change the account that your service runs under to one
that has the requested permissions on the remote machine.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Robert" wrote:
Nicolas,
The exception is:
UnauthorizedAccessException

Timer in the main service body is from System.Threading library.

The example link I mentioned is the code.

Inside timer callback after files transfered I just move files from Folder1
to Folder2.

The FTP transfer goes fast, actually there are just 2 files only for now.

I can see them inside remote folder... but Ftp request blocks them only if I
use this code inside service.

As I mentioned before if placed in standalone aplication - works fine.

Sep 25 '07 #4
Peter,

Here is the code snap where the exception is:

public void GlobalTick_Tick(Object stateInfo)

{
Action act = new Action(); <--FTP transfer here Ok
string from = "FolderFrom&File"; <= One of the transfered
files (LocalPC)
string where = "FolderTo&File";<= (local PC)
if (File.Exists(from) && !File.Exists(where))
{
Logger.Record("Moved from: " + from + " To: " + where);
try
{
File.SetAttributes(from, FileAttributes.Normal);<--
here's the Exception
File.Copy(from, where);<-- here's the Exception
File.Delete(from);<-- here's the Exception

}
catch (UnauthorizedAccessException ex)
{
throw ex;
}
}
}

Files are blocked for FTP request, though I close request stream and file
stream, and even I lock and unlock the file stream during FTP transfer, and
Timer doesn't come to that point yet.....as the transfer itself takes only 2
seconds and timer set up for every 10 seconds.

How to set up the credentials for remote? I use the right username and
password to login the FTP server folder, and I see how files are moved there.

Anything I lost? Please, clearify the idea.

Thanks

Sep 25 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: doug.h.taylor.accipitersoftware.com | last post by:
Hi, I need a general direction. I don't even know where to start researching how to do this. I have an existing dot net web application (It's mine, I wrote it) that has some text fields and...
2
by: George Jin | last post by:
My windows service program can not connect to the internet. But if it runs as a stand along program, it looks perfectly and can connect internet. ANy one knows why my windows service can not...
5
by: Dhilip Kumar | last post by:
Hi All, I'm writing a Windows Service app using C#. I need to read some configuration settings before the service starts up. These settings will be used by the service in its operation. ...
3
by: Angshuman Agarwal | last post by:
Hello, I have written a Windows Service in VB6 and a VB Dll separately. When I call the DLL normally in VB (i.e. by adding the reference in some other form) it works fine , but if I try calling...
4
by: Blaxer | last post by:
I have read approximately 30 articles now on various methods to make your vb.net application automatically update itself and I can't see how they apply to a vb.net windows services projects. The...
3
by: alegon | last post by:
Hi... I´m making an instaler for the windows service I've recently develop, my sevice needs a few config files to be located on the same path of the executable file of the service, when I install...
4
by: Niron kag | last post by:
Hi, I have a windows service, which is currently installed, on my local computer. The problem is that when I look at the task manager, I see that the “Mem Usage”, become bigger and bigger....
0
by: savajx1 | last post by:
I am loading signed assemblies from a network share. The assemblies are NOT INSTALLED in the GAC as they are part of an enterprise distributed application implemented as a windows service that...
3
by: Matthias S. | last post by:
Hi there, i'm planning on creating a Windows Service, which will have a simple loop in its OnStart override. In this loop, I dynamically want to load (job) Assemblies which have a single class...
1
by: sutch | last post by:
I have created a DDE( Dynamic-Data Exchange) Client (Console) application to interact with a legacy DDE Server. This client is working perfectly I am asked to develop same functionality in a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.