|
|
|
i want to upload a file to ftp server using simple C# widows service application, and this is my code
protected void UploadToFTP(string path, string name)
{
string strLocation = string.Format(ftpfullpath + "/{0}.txt", strNewFtpName);
// FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create("ftp://192.168.10.239/test.txt");
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(strLocation);
ftp.Credentials = new NetworkCredential(strFtpUsername, StrftpPassowrd);
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
FileStream fs = File.OpenRead(source);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length);
ftpstream.Close();
}
when i test this application .txt file is created in FTP server.
But when i run a window service the .txt file is not created(uploaded) on FTP server. How do i solve this??
|
|
|
|
|
You should add some trace code so that you can see what happens when running as a service.
Use the best guess
|
|
|
|
|
Windows service is running successfully.
i have also logged the messages step by step.
It tells File uploaded successfully with its respective file name.
But file not created on FTP server.
|
|
|
|
|
susanna.floora wrote: It tells File uploaded successfully with its respective file name. But you are not checking the FTP response so you cannot be sure of that.
Use the best guess
|
|
|
|
|
What happens when you run that service under your account instead of Local System or Network System?
|
|
|
|
|
I tried the same code, the same procedure in different machine.. it works fine..
But why not it works in my system?
|
|
|
|
|
Hi,
I am suffering a bug in VS 2012R2, and reported same.(Builds fail before they start, citing an internal error.) In response I was invited to supply further info, such as a stack dump using a Bug Reporting Tool. for which MS provided a link. I downloaded a File:"Quote: Microsoft.VisualStudio.FeedbackTool.vsix
How do I integrate this with the IDE. The MS instructions are to install it by downloading it. It intimates that after downloading, it should appear on the bottom ribbon, (which it does not), and can be invoked from the 'Help\Report Bug' menu. That's also not the case!
Where do I go from here!
Bram van Kampen
modified 25-Jun-13 20:20pm.
|
|
|
|
|
|
Hello,
I want to create a windows service that will act as a connection pool manager for a 3rd party tool to various apps (web, utilities, etc) that are running on same server. I'm struggling with how the other apps call this service without creating additional instances of the exe. I've played with load assembly and references and it seemingly is creating an additional instance.
Proof: I have a static class that is populated (initialized) upon load of the service. When an app tries to create an instance of a different class that calls methods within the static class...the static class is empty (uninitialized). So my conclusuion is a second instance is created?
How can I design this to do what I'm looking for...
Thank you for your time...
Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
|
|
|
|
|
nlarson11 wrote: When an app tries to create an instance of a different class that calls methods within the static class...the static class is empty (uninitialized). So my conclusuion is a second instance is created? Within that application; a static class is loaded only once per application-domain.
Why does it have to be a Windows Service? If you're referencing it, or loading it in another app, then it is being used as a class-library.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello Eddy, thank you for your response...
Windows service vs a class-library: My apps include a classic asp website, a asp.net wcf service site, a asp.net webforms site, a asp.net mvc site, as well as scheduled tasks. What keeps that library running and accessible from all calling apps? The intent is to use one pool, not one per app to cut down on the number of connections to our mainframe. The 3rd party tool creates two connections (first is to establish connection, second is the actual call to the service) per transaction to be able to call a specific service on our mainframe. The first connection can be "cached" / held on to which is what the pool manager is intended to do.
Thanks again for your time..
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
nlarson11 wrote: The first connection can be "cached" / held on to which is what the pool manager is intended to do. It's still unclear where your class "is" - and the list of web-based apps doesn't simplify that.
Where does the connection manager get it's connections from?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Sorry - never been gifted in painting a picture
The pool, connections, and transactions to the mainframe are all created/handled in the windows service. An app creates an instance to a class within the windows service that will execute transaction logic making it's way to the mainframe. This logic checks first if the pool has a link and uses it if it does or creates a link and then passes it to the pool to hold on to.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
nlarson11 wrote: The pool, connections, and transactions to the mainframe are all created/handled in the windows service The Pool , Connection and Transaction are managed .NET classes? If yes, which clients will be using those classes?
The static classes in there will be unique per AppDomain. You can't a static class to share resources among different applications - there's not a static class that's "global" across applications.
A Windows-Service would only be usefull if there's an app that needs to run without user-supervision. It'd be comparable to writing a server-application, and yes, you could communicate with that.
Is there an unmanaged resource that the Pool is protecting? What kind of connection is the user expecting? It "feels" like you're trying to limit database-connections - am I right?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
In C#,How to generate Tree View in List View control with all treeview functionalities.
Jai Deo Tiwari
Bharat-560038
|
|
|
|
|
Why don't you use the TreeView instead of a ListView? Then you would have all TreeView fucntionalities?
Author of Primary ROleplaying SysTem
How do I take my coffee? Black as midnight on a moonless night.
War doesn't determine who's right. War determines who's left.
|
|
|
|
|
if i want authenticate the access on my ip address, what do i do?
the ipcamera in its home page has the authentication or as a simple user or as a administrator..
if i use HttpWebRequest i do the access with the credentials, but then i can't view the streaming, i think because the authentication executes every time.. have you a solution?
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Credentials = new NetworkCredential("user", "password");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
modified 25-Jun-13 8:12am.
|
|
|
|
|
Please edit your message and remove the <big> tags around your text. The standard font size will get your question just as much attention.
Use the best guess
|
|
|
|
|
Nick_Frenk wrote: i think because the authentication executes every time.. have you a solution? I'm not a webprogrammer, but I think you might need to store a "cookie". How about using the WebBrowser component to get to the page? It'd store the cookie on it's own once your logged in.
The WebRequest can do the trick too, but you'd have to dig into the usage of the CookieContainer[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks for your reply, probably you have right..
|
|
|
|
|
hi
i have this error and i don't know how i fix it.
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: windowsformsapplication3.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 51c8d50d
Problem Signature 04: WindowsFormsApplication3
Problem Signature 05: 1.0.0.0
Problem Signature 06: 51c8d50d
Problem Signature 07: 299
Problem Signature 08: 16
Problem Signature 09: System.IO.FileNotFoundException
OS Version: 6.2.9200.2.0.0.768.101
Locale ID: 1032
Additional Information 1: 5861
Additional Information 2: 5861822e1919d7c014bbb064c64908b2
Additional Information 3: f3d5
Additional Information 4: f3d5be0cad2787556264647dc02181c3
|
|
|
|
|
zebra88 wrote: System.IO.FileNotFoundException
You would need to find out which file your application is trying to use and is missing and add it to your setup program.
|
|
|
|
|
Make sure you have the right folder structure while installing this program.
A file might be getting missed.
|
|
|
|